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; }
|
[ "$STATUS" = "running" ] || { echo "FAIL: frontend non running"; exit 1; }
|
||||||
echo "PASS: frontend running"
|
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
|
- name: healthcheck
|
||||||
image: alpine:3.20
|
image: docker:27-cli
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- /opt/dtrack:/opt/dtrack
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache --quiet curl
|
|
||||||
- |
|
- |
|
||||||
DOMAIN=$(grep '^DTRACK_DOMAIN=' .env.deploy | cut -d= -f2)
|
PROJECT=$(grep '^COMPOSE_PROJECT_NAME=' /opt/dtrack/.env | cut -d= -f2)
|
||||||
if [ -z "$DOMAIN" ]; then
|
echo "Attente healthcheck Docker sur $PROJECT-apiserver (max 5 min)..."
|
||||||
echo "ERREUR: DTRACK_DOMAIN non defini dans .env.deploy"
|
MAX=30
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
TARGET="https://$DOMAIN/api/version"
|
|
||||||
echo "Healthcheck sur $TARGET (max 2 minutes)..."
|
|
||||||
MAX=12
|
|
||||||
i=0
|
i=0
|
||||||
until [ $i -ge $MAX ]; do
|
until [ $i -ge $MAX ]; do
|
||||||
RESPONSE=$(curl -sf "$TARGET" 2>/dev/null)
|
HEALTH=$(docker inspect --format '{{.State.Health.Status}}' "$PROJECT-apiserver" 2>/dev/null || echo "absent")
|
||||||
if [ $? -eq 0 ]; then
|
echo "Tentative $((i+1))/$MAX — $PROJECT-apiserver : $HEALTH"
|
||||||
echo "PASS: apiserver repond"
|
[ "$HEALTH" = "healthy" ] && echo "PASS: apiserver healthy" && exit 0
|
||||||
echo "version: $RESPONSE"
|
[ "$HEALTH" = "absent" ] && echo "FAIL: conteneur introuvable" && exit 1
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
echo "Tentative $i/$MAX - retry dans 10s"
|
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
echo "ERREUR: apiserver ne repond pas apres 2 minutes"
|
echo "FAIL: apiserver non healthy apres 5 minutes"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
# Notification en cas d'echec
|
# Notification en cas d'echec
|
||||||
|
|||||||
Reference in New Issue
Block a user