fix: relax web→api dependency + smarter wait loop
- web's depends_on on api: change from service_healthy to service_started+restart (same as api→postgres fix) - deploy wait loop: fail fast on unhealthy, wait on starting, increased timeout to 180s (36×5s)
This commit is contained in:
@@ -220,19 +220,26 @@ jobs:
|
|||||||
docker compose --env-file /tmp/nexus-deploy-env build ${BUILD_ARGS}
|
docker compose --env-file /tmp/nexus-deploy-env build ${BUILD_ARGS}
|
||||||
docker compose --env-file /tmp/nexus-deploy-env up -d --force-recreate
|
docker compose --env-file /tmp/nexus-deploy-env up -d --force-recreate
|
||||||
fi
|
fi
|
||||||
echo '⏳ Waiting for services to become healthy (up to 120s)...'
|
echo '⏳ Waiting for services to become healthy (up to 180s)...'
|
||||||
for i in \$(seq 1 24); do
|
for i in \$(seq 1 36); do
|
||||||
STATUS=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | tail -n +2)
|
UNHEALTHY=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | grep -E 'unhealthy' || true)
|
||||||
if echo \"\$STATUS\" | grep -q 'unhealthy\|starting'; then
|
STARTING=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | grep -E 'starting' || true)
|
||||||
echo \" [\$i/24] Waiting...\"
|
if [ -n \"\$UNHEALTHY\" ]; then
|
||||||
|
echo \" [\$i/36] Containers unhealthy:\"
|
||||||
|
echo \"\$UNHEALTHY\"
|
||||||
|
echo \"Failing fast — unhealthy container detected\"
|
||||||
|
docker compose --env-file /tmp/nexus-deploy-env logs --tail=30
|
||||||
|
exit 1
|
||||||
|
elif [ -n \"\$STARTING\" ]; then
|
||||||
|
echo \" [\$i/36] Still starting...\"
|
||||||
sleep 5
|
sleep 5
|
||||||
else
|
else
|
||||||
echo '✅ All containers running'
|
echo '✅ All containers healthy'
|
||||||
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo '❌ Timeout waiting for services'
|
echo '❌ Timeout waiting for services (180s)'
|
||||||
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
docker compose --env-file /tmp/nexus-deploy-env ps -a
|
||||||
docker compose --env-file /tmp/nexus-deploy-env logs --tail=20
|
docker compose --env-file /tmp/nexus-deploy-env logs --tail=20
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
+2
-1
@@ -113,7 +113,8 @@ services:
|
|||||||
- "127.0.0.1:18880:80"
|
- "127.0.0.1:18880:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
api:
|
api:
|
||||||
condition: service_healthy
|
condition: service_started
|
||||||
|
restart: true
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "curl -f http://localhost:80/ || exit 1"]
|
test: ["CMD-SHELL", "curl -f http://localhost:80/ || exit 1"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|||||||
Reference in New Issue
Block a user