From baf4008d9702e21ae22917ed3225d59f87fcbd45 Mon Sep 17 00:00:00 2001 From: DevOps Date: Sat, 20 Jun 2026 18:46:27 +0200 Subject: [PATCH] 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. --- .gitea/workflows/deploy.yaml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 0050ee5..facc19c 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -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"