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
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
STATUS=$(sudo docker compose -f "$COMPOSE_FILE" ps --format json | jq -r '.[] | select(.Name=="stargirlnails-app" or .Service=="stargirlnails") | .State') || true
if echo "$STATUS" | grep -qi "running"; then
# Optional: also check the container health if reported
HEALTH=$(sudo docker compose -f "$COMPOSE_FILE" ps --format json | jq -r '.[] | select(.Name=="stargirlnails-app" or .Service=="stargirlnails") | .Health') || true
if [ -z "$HEALTH" ] || echo "$HEALTH" | grep -qi "healthy"; then
echo "Service is running${HEALTH:+ and healthy}."
break
fi
# Check health status if available
HEALTH=$(sudo docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' stargirlnails-app 2>/dev/null || true)
if [ "$HEALTH" = "healthy" ]; then
echo "Service is healthy."
break
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
done