From b95bec7915eb660cc2d26ec57a1f601444ef3354 Mon Sep 17 00:00:00 2001 From: DevOps Date: Sat, 20 Jun 2026 18:50:29 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20relax=20web=E2=86=92api=20dependency=20+?= =?UTF-8?q?=20smarter=20wait=20loop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- .gitea/workflows/deploy.yaml | 21 ++++++++++++++------- compose.yaml | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index facc19c..67840a4 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -220,19 +220,26 @@ jobs: docker compose --env-file /tmp/nexus-deploy-env build ${BUILD_ARGS} 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...\" + echo '⏳ Waiting for services to become healthy (up to 180s)...' + for i in \$(seq 1 36); do + UNHEALTHY=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | grep -E 'unhealthy' || true) + STARTING=\$(docker compose --env-file /tmp/nexus-deploy-env ps -a 2>/dev/null | grep -E 'starting' || true) + 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 else - echo '✅ All containers running' + echo '✅ All containers healthy' docker compose --env-file /tmp/nexus-deploy-env ps -a exit 0 fi 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 logs --tail=20 exit 1 diff --git a/compose.yaml b/compose.yaml index 6a190b5..0218a54 100644 --- a/compose.yaml +++ b/compose.yaml @@ -113,7 +113,8 @@ services: - "127.0.0.1:18880:80" depends_on: api: - condition: service_healthy + condition: service_started + restart: true healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:80/ || exit 1"] interval: 30s