diff --git a/scripts/deploy.sh b/scripts/deploy.sh index ecbd9ce..c00679a 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -96,13 +96,25 @@ docker compose up -d --build $BUILD_TARGETS docker exec frontend nginx -s reload 2>/dev/null || true # ── 배포 후 헬스체크 ── -echo "Waiting for services to start..." -sleep 5 +# Docker compose의 healthcheck 블록이 이미 모든 컨테이너에 정의되어 있으므로 +# `docker inspect`로 컨테이너 health state를 직접 조회. 이 방식은 +# (a) deployer 컨테이너 내부에서도 호스트에서도 동일하게 동작 +# (b) 호스트네임 DNS 해석에 의존하지 않음 (호스트 셸에서는 'lotto' 등 미해석) +echo "Waiting for services to become healthy..." HEALTH_OK=true for svc in $HEALTH_ENDPOINTS; do - if ! curl -sf --max-time 10 --retry 2 --retry-delay 3 "http://$svc:8000/health" > /dev/null 2>&1; then - echo "HEALTH_FAIL: http://$svc:8000/health" + health="starting" + # 최대 60초 (5초×12) 동안 starting → healthy 전이 대기 + for _ in $(seq 1 12); do + health=$(docker inspect --format='{{.State.Health.Status}}' "$svc" 2>/dev/null || echo "missing") + if [ "$health" = "healthy" ] || [ "$health" = "unhealthy" ] || [ "$health" = "missing" ]; then + break + fi + sleep 5 + done + if [ "$health" != "healthy" ]; then + echo "HEALTH_FAIL: $svc (state=$health)" HEALTH_OK=false fi done