Files
AFC-Demo/deploy/entrypoint.sh
T

44 lines
1.3 KiB
Bash
Raw Normal View History

2025-10-23 08:10:45 +02:00
#!/usr/bin/env sh
set -e
2025-10-23 08:25:29 +02:00
# Default: DO NOT run artisan on boot (avoid provider issues)
: "${ARTISAN_BOOT:=0}"
: "${ARTISAN_DB_WAIT:=0}"
: "${ARTISAN_MIGRATE:=0}"
: "${ARTISAN_VERBOSE:=0}"
2025-10-23 08:10:45 +02:00
log() { [ "$ARTISAN_VERBOSE" = "1" ] && echo "[entrypoint] $*"; }
warn() { echo "[entrypoint] $*" 1>&2; }
cd /var/www/html || true
2025-10-23 08:25:29 +02:00
if [ "$ARTISAN_BOOT" != "1" ] || [ ! -f artisan ]; then
[ ! -f artisan ] && warn "artisan not found; skipping artisan."
2025-10-23 08:10:45 +02:00
exec /usr/bin/supervisord -c /etc/supervisord.conf
fi
if [ "$ARTISAN_DB_WAIT" = "1" ] && [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ]; then
log "Waiting for DB ${DB_HOST}:${DB_PORT} ..."
i=0
until php -r '
$h=getenv("DB_HOST"); $p=(int)getenv("DB_PORT")?:5432;
$s=@fsockopen($h,$p,$errno,$errstr,1.0);
if($s){fclose($s); exit(0);} exit(1);
'; do
2025-10-23 08:25:29 +02:00
i=$((i+1)); [ $i -gt 60 ] && warn "DB wait timed out after 60s" && break
2025-10-23 08:10:45 +02:00
sleep 1
done
fi
2025-10-23 08:25:29 +02:00
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."
2025-10-23 08:10:45 +02:00
fi
2025-10-23 08:25:29 +02:00
[ "$ARTISAN_MIGRATE" = "1" ] && php artisan migrate --force --no-interaction --ansi || true
2025-10-23 08:10:45 +02:00
exec /usr/bin/supervisord -c /etc/supervisord.conf