fix: build and permissions
This commit is contained in:
1 parent
8492f2cc33
commit
ea351d2e6d
6 files changed
+57
-74
No files matched your search
+16
-31
@@ -1,31 +1,23 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
# -------- Options (env flags) --------
|
||||
: "${ARTISAN_BOOT:=1}" # set to 0 to skip all artisan work
|
||||
: "${ARTISAN_DB_WAIT:=0}" # set to 1 to wait for DB before artisan
|
||||
: "${ARTISAN_MIGRATE:=0}" # set to 1 to run php artisan migrate --force
|
||||
: "${ARTISAN_HORIZON:=0}" # set to 1 to start Horizon under supervisord (add program if you want)
|
||||
: "${ARTISAN_VERBOSE:=0}" # set to 1 for more logs
|
||||
# Default: DO NOT run artisan on boot (avoid provider issues)
|
||||
: "${ARTISAN_BOOT:=0}"
|
||||
: "${ARTISAN_DB_WAIT:=0}"
|
||||
: "${ARTISAN_MIGRATE:=0}"
|
||||
: "${ARTISAN_VERBOSE:=0}"
|
||||
|
||||
log() { [ "$ARTISAN_VERBOSE" = "1" ] && echo "[entrypoint] $*"; }
|
||||
warn() { echo "[entrypoint] $*" 1>&2; }
|
||||
|
||||
cd /var/www/html || true
|
||||
|
||||
if [ "$ARTISAN_BOOT" != "1" ]; then
|
||||
log "ARTISAN_BOOT=0 → skipping artisan boot steps."
|
||||
if [ "$ARTISAN_BOOT" != "1" ] || [ ! -f artisan ]; then
|
||||
[ ! -f artisan ] && warn "artisan not found; skipping artisan."
|
||||
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
if [ ! -f artisan ]; then
|
||||
warn "artisan not found; skipping artisan steps."
|
||||
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
# -------- Optional: wait for Postgres --------
|
||||
if [ "$ARTISAN_DB_WAIT" = "1" ] && [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ]; then
|
||||
# Use PHP + sockets to test TCP if pg_isready isn't available
|
||||
log "Waiting for DB ${DB_HOST}:${DB_PORT} ..."
|
||||
i=0
|
||||
until php -r '
|
||||
@@ -33,26 +25,19 @@ if [ "$ARTISAN_DB_WAIT" = "1" ] && [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ]; then
|
||||
$s=@fsockopen($h,$p,$errno,$errstr,1.0);
|
||||
if($s){fclose($s); exit(0);} exit(1);
|
||||
'; do
|
||||
i=$((i+1))
|
||||
if [ $i -gt 60 ]; then
|
||||
warn "DB wait timed out after 60s — continuing anyway."
|
||||
break
|
||||
fi
|
||||
i=$((i+1)); [ $i -gt 60 ] && warn "DB wait timed out after 60s" && break
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
# -------- Safe, cache-warming steps --------
|
||||
# Don’t fail the container if any step errors (env may be partial in some setups)
|
||||
php artisan package:discover --ansi || warn "package:discover failed"
|
||||
php artisan config:cache --ansi || warn "config:cache failed"
|
||||
php artisan route:cache --ansi || warn "route:cache failed"
|
||||
php artisan view:cache --ansi || warn "view:cache failed"
|
||||
|
||||
# -------- (Optional) database migrations --------
|
||||
if [ "$ARTISAN_MIGRATE" = "1" ]; then
|
||||
php artisan migrate --force --no-interaction --ansi || warn "migrate failed"
|
||||
if php artisan package:discover --ansi; then
|
||||
php artisan config:cache --ansi || warn "config:cache failed"
|
||||
php artisan route:cache --ansi || warn "route:cache failed"
|
||||
php artisan view:cache --ansi || warn "view:cache failed"
|
||||
else
|
||||
warn "package:discover failed — skipping caches."
|
||||
fi
|
||||
|
||||
# -------- Hand off to supervisord --------
|
||||
[ "$ARTISAN_MIGRATE" = "1" ] && php artisan migrate --force --no-interaction --ansi || true
|
||||
|
||||
exec /usr/bin/supervisord -c /etc/supervisord.conf
|
||||
Reference in new issue
Block a user