diff --git a/scripts/ci/deploy-container.sh b/scripts/ci/deploy-container.sh index ba804064..d57b4f42 100755 --- a/scripts/ci/deploy-container.sh +++ b/scripts/ci/deploy-container.sh @@ -57,6 +57,25 @@ case "$CMD" in run run -d --name flights-web --restart unless-stopped \ -p "127.0.0.1:${PORT}:8080" \ "${IMAGE}:current" + # 5. Wait for the SSR inside the container to start listening before + # returning. Without this, the next nginx-side probe gets a few + # 502s while Node.js is still booting — works (wait-for-url.sh + # retries) but adds noise to the deploy log. + if [ "$DRY_RUN" -eq 0 ]; then + attempt=1 + while [ "$attempt" -le 30 ]; do + if curl -fsS -o /dev/null "http://127.0.0.1:${PORT}/"; then + echo "swap: SSR ready on :${PORT} after $attempt attempt(s)" + break + fi + if [ "$attempt" -eq 30 ]; then + echo "swap: SSR did not respond on :${PORT} after 30 attempts" >&2 + exit 1 + fi + sleep 1 + attempt=$((attempt + 1)) + done + fi ;; rollback) if [ "$DRY_RUN" -eq 0 ] && ! docker image inspect "${IMAGE}:previous" >/dev/null 2>&1; then