diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8de207c..74cbc46 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -35,7 +35,20 @@ echo "====================== Installing NPM dependencies and building frontend.. /usr/bin/npm run build echo "====================== Running migrations... ====================== " -/usr/local/bin/php artisan migrate --force +run_migrations() { + /usr/local/bin/php artisan migrate --force +} +RETRIES=30 +DELAY=5 +until run_migrations; do + RETRIES=$((RETRIES-1)) + if [ $RETRIES -le 0 ]; then + echo "Database is not ready after multiple attempts. Exiting..." + exit 1 + fi + echo "Waiting for database to be ready... retrying in $DELAY seconds." + sleep $DELAY +done echo "====================== Spinning up Supervisor daemon... ====================== " exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf