diff --git a/.gitea/workflows/production.yaml b/.gitea/workflows/production.yaml index be31175..27a6bb7 100644 --- a/.gitea/workflows/production.yaml +++ b/.gitea/workflows/production.yaml @@ -253,6 +253,49 @@ jobs: - name: Wait for routing propagation run: sleep 5 + - name: Check container status and health + run: | + for service in mvp-frontend-$TARGET_STACK mvp-backend-$TARGET_STACK mvp-ocr; do + status=$(docker inspect --format='{{.State.Status}}' $service 2>/dev/null || echo "not found") + if [ "$status" != "running" ]; then + echo "ERROR: $service is not running (status: $status)" + docker logs $service --tail 50 2>/dev/null || true + exit 1 + fi + echo "OK: $service is running" + done + + # Wait for Docker healthchecks to complete (services with healthcheck defined) + echo "" + echo "Waiting for Docker healthchecks..." + for service in mvp-frontend-$TARGET_STACK mvp-backend-$TARGET_STACK mvp-ocr; do + # Check if service has a healthcheck defined + has_healthcheck=$(docker inspect --format='{{if .Config.Healthcheck}}true{{else}}false{{end}}' $service 2>/dev/null || echo "false") + if [ "$has_healthcheck" = "true" ]; then + # 24 attempts x 10 seconds = 4 minutes max wait (backend with fresh migrations can take ~3 min) + for i in $(seq 1 24); do + health=$(docker inspect --format='{{.State.Health.Status}}' $service 2>/dev/null || echo "unknown") + if [ "$health" = "healthy" ]; then + echo "OK: $service is healthy" + break + elif [ "$health" = "unhealthy" ]; then + echo "ERROR: $service is unhealthy" + docker logs $service --tail 50 2>/dev/null || true + exit 1 + fi + if [ $i -eq 24 ]; then + echo "ERROR: $service health check timed out (status: $health)" + docker logs $service --tail 50 2>/dev/null || true + exit 1 + fi + echo "Waiting for $service healthcheck... (attempt $i/24, status: $health)" + sleep 10 + done + else + echo "SKIP: $service has no healthcheck defined" + fi + done + - name: External health check run: | REQUIRED_FEATURES='["admin","auth","onboarding","vehicles","documents","fuel-logs","stations","maintenance","platform","notifications","user-profile","user-preferences","user-export"]'