Prod: rebuild script Healthcheck ohne jq (docker inspect fallback)

This commit is contained in:
2025-10-05 20:21:31 +02:00
parent 9c2e47ef9a
commit 244eeee142

View File

@@ -26,17 +26,22 @@ echo "[5/7] Start services in background"
sudo docker compose -f "$COMPOSE_FILE" up -d sudo docker compose -f "$COMPOSE_FILE" up -d
echo "[6/7] Wait for app healthcheck to pass" echo "[6/7] Wait for app healthcheck to pass"
# Wait up to ~90s for healthy status # Wait up to ~90s for healthy status using docker inspect (no jq dependency)
for i in {1..18}; do for i in {1..18}; do
STATUS=$(sudo docker compose -f "$COMPOSE_FILE" ps --format json | jq -r '.[] | select(.Name=="stargirlnails-app" or .Service=="stargirlnails") | .State') || true # Check health status if available
if echo "$STATUS" | grep -qi "running"; then HEALTH=$(sudo docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' stargirlnails-app 2>/dev/null || true)
# Optional: also check the container health if reported if [ "$HEALTH" = "healthy" ]; then
HEALTH=$(sudo docker compose -f "$COMPOSE_FILE" ps --format json | jq -r '.[] | select(.Name=="stargirlnails-app" or .Service=="stargirlnails") | .Health') || true echo "Service is healthy."
if [ -z "$HEALTH" ] || echo "$HEALTH" | grep -qi "healthy"; then break
echo "Service is running${HEALTH:+ and healthy}."
break
fi
fi fi
# Fallback: ensure container is running
STATE=$(sudo docker inspect -f '{{.State.Status}}' stargirlnails-app 2>/dev/null || true)
if [ "$STATE" = "running" ] && [ -z "$HEALTH" ]; then
echo "Service is running (no healthcheck reported)."
break
fi
sleep 5 sleep 5
done done