first commit
This commit is contained in:
27
backend/entrypoint.sh
Normal file
27
backend/entrypoint.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Immagine php:8.4-fpm-alpine: niente bash, solo /bin/sh (busybox ash).
|
||||
# set -eu basta (nessuna pipe nello script → pipefail non serve e non è POSIX).
|
||||
set -eu
|
||||
|
||||
echo "Waiting for database connection..."
|
||||
|
||||
# Riprova la connessione finché MySQL non risponde (max ~60s)
|
||||
ATTEMPTS=0
|
||||
until php artisan db:show >/dev/null 2>&1; do
|
||||
ATTEMPTS=$((ATTEMPTS + 1))
|
||||
if [ "$ATTEMPTS" -ge 30 ]; then
|
||||
echo "MySQL not reachable after 60s, exiting." >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "MySQL ready. Executing pending migrations (idempotent)..."
|
||||
|
||||
# --force: niente prompt interattivo
|
||||
# migrate normale: applica SOLO le migration non ancora eseguite, non tocca i dati esistenti
|
||||
php artisan migrate --force
|
||||
|
||||
# Avvia il processo principale passato come CMD (php-fpm, artisan serve, ecc.)
|
||||
echo "Starting application..."
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user