fix: remove --wait flag causing premature deploy failure, use manual health loop
The docker compose --wait flag times out before postgres can become healthy (start_period=30s). Replaced with explicit poll loop (5s interval, up to 120s) that checks ps output for unhealthy/starting states.
This commit is contained in:
@@ -214,12 +214,28 @@ jobs:
|
||||
if [ -n '${SERVICE_ARG}' ]; then
|
||||
echo '🚀 Deploying service: ${SERVICE_ARG}'
|
||||
docker compose --env-file /tmp/nexus-deploy-env build ${BUILD_ARGS} ${SERVICE_ARG}
|
||||
docker compose --env-file /tmp/nexus-deploy-env up -d --wait --force-recreate ${SERVICE_ARG}
|
||||
docker compose --env-file /tmp/nexus-deploy-env up -d --force-recreate ${SERVICE_ARG}
|
||||
else
|
||||
echo '🚀 Deploying all services'
|
||||
docker compose --env-file /tmp/nexus-deploy-env build ${BUILD_ARGS}
|
||||
docker compose --env-file /tmp/nexus-deploy-env up -d --wait --force-recreate
|
||||
docker compose --env-file /tmp/nexus-deploy-env up -d --force-recreate
|
||||
fi
|
||||
echo '⏳ Waiting for services to become healthy (up to 120s)...'
|
||||
for i in \$(seq 1 24); do
|
||||
STATUS=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | tail -n +2)
|
||||
if echo \"\$STATUS\" | grep -q 'unhealthy\|starting'; then
|
||||
echo \" [\$i/24] Waiting...\"
|
||||
sleep 5
|
||||
else
|
||||
echo '✅ All containers running'
|
||||
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo '❌ Timeout waiting for services'
|
||||
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
||||
docker compose --env-file /tmp/nexus-deploy-env logs --tail=20
|
||||
exit 1
|
||||
" < "${ENV_TMPFILE}"
|
||||
|
||||
echo "✅ Docker compose up completed"
|
||||
|
||||
Reference in New Issue
Block a user