fix(ci): healthcheck via docker inspect — pas de requete HTTPS publique (Fabio non configure)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -74,33 +74,28 @@ steps:
|
||||
[ "$STATUS" = "running" ] || { echo "FAIL: frontend non running"; exit 1; }
|
||||
echo "PASS: frontend running"
|
||||
|
||||
# Etape 3 : Healthcheck HTTP sur l'apiserver
|
||||
# Etape 3 : Healthcheck via Docker — poll le statut interne du conteneur
|
||||
# Pas de requete HTTPS publique : Fabio/TLS ne sont pas encore configures ici
|
||||
- name: healthcheck
|
||||
image: alpine:3.20
|
||||
image: docker:27-cli
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /opt/dtrack:/opt/dtrack
|
||||
commands:
|
||||
- apk add --no-cache --quiet curl
|
||||
- |
|
||||
DOMAIN=$(grep '^DTRACK_DOMAIN=' .env.deploy | cut -d= -f2)
|
||||
if [ -z "$DOMAIN" ]; then
|
||||
echo "ERREUR: DTRACK_DOMAIN non defini dans .env.deploy"
|
||||
exit 1
|
||||
fi
|
||||
TARGET="https://$DOMAIN/api/version"
|
||||
echo "Healthcheck sur $TARGET (max 2 minutes)..."
|
||||
MAX=12
|
||||
PROJECT=$(grep '^COMPOSE_PROJECT_NAME=' /opt/dtrack/.env | cut -d= -f2)
|
||||
echo "Attente healthcheck Docker sur $PROJECT-apiserver (max 5 min)..."
|
||||
MAX=30
|
||||
i=0
|
||||
until [ $i -ge $MAX ]; do
|
||||
RESPONSE=$(curl -sf "$TARGET" 2>/dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "PASS: apiserver repond"
|
||||
echo "version: $RESPONSE"
|
||||
exit 0
|
||||
fi
|
||||
HEALTH=$(docker inspect --format '{{.State.Health.Status}}' "$PROJECT-apiserver" 2>/dev/null || echo "absent")
|
||||
echo "Tentative $((i+1))/$MAX — $PROJECT-apiserver : $HEALTH"
|
||||
[ "$HEALTH" = "healthy" ] && echo "PASS: apiserver healthy" && exit 0
|
||||
[ "$HEALTH" = "absent" ] && echo "FAIL: conteneur introuvable" && exit 1
|
||||
i=$((i+1))
|
||||
echo "Tentative $i/$MAX - retry dans 10s"
|
||||
sleep 10
|
||||
done
|
||||
echo "ERREUR: apiserver ne repond pas apres 2 minutes"
|
||||
echo "FAIL: apiserver non healthy apres 5 minutes"
|
||||
exit 1
|
||||
|
||||
# Notification en cas d'echec
|
||||
|
||||
Reference in New Issue
Block a user