Files
AFC-Demo/deploy/entrypoint.sh
T
2025-10-23 08:25:29 +02:00

44 lines
1.3 KiB
Bash

#!/usr/bin/env sh
set -e
# 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" ] || [ ! -f artisan ]; then
[ ! -f artisan ] && warn "artisan not found; skipping artisan."
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
i=$((i+1)); [ $i -gt 60 ] && warn "DB wait timed out after 60s" && break
sleep 1
done
fi
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
[ "$ARTISAN_MIGRATE" = "1" ] && php artisan migrate --force --no-interaction --ansi || true
exec /usr/bin/supervisord -c /etc/supervisord.conf