add docker files

This commit is contained in:
canguilieme julien 2024-10-07 22:12:10 +02:00
parent 0ab3c83eab
commit e20a92368e

View File

@ -26,7 +26,7 @@ deploy-job:
- deploiement - deploiement
script: script:
- | - |
set -x set -e
echo "Déploiement sur Portainer..." echo "Déploiement sur Portainer..."
echo "Utilisation du token API de Portainer..." echo "Utilisation du token API de Portainer..."
@ -34,26 +34,22 @@ deploy-job:
if [ -z "$PORTAINER_API_KEY" ]; then echo "Erreur : PORTAINER_API_KEY non définie."; exit 1; fi if [ -z "$PORTAINER_API_KEY" ]; then echo "Erreur : PORTAINER_API_KEY non définie."; exit 1; fi
if [ -z "$PORTAINER_URL" ]; then echo "Erreur : PORTAINER_URL non définie."; exit 1; fi if [ -z "$PORTAINER_URL" ]; then echo "Erreur : PORTAINER_URL non définie."; exit 1; fi
if [ -z "$STACK_ID" ]; then echo "Erreur : STACK_ID non définie."; exit 1; fi if [ -z "$STACK_ID" ]; then echo "Erreur : STACK_ID non définie."; exit 1; fi
if [ -z "$ENDPOINT_ID" ]; then echo "Erreur : ENDPOINT_ID non définie."; exit 1; fi
# Affichage des variables (sauf les sensibles) echo "Déclenchement du redeploiement de la stack Git sur Portainer..."
echo "PORTAINER_URL : $PORTAINER_URL"
echo "STACK_ID : $STACK_ID"
echo "Déploiement de la stack sur Portainer..." # Exécuter la requête pour redeployer la stack Git
RESPONSE=$(curl -s -k -w "%{http_code}" -X POST \
RESPONSE=$(curl -v -X PUT \
-H "Authorization: Bearer $PORTAINER_API_KEY" \ -H "Authorization: Bearer $PORTAINER_API_KEY" \
-H "Content-Type: application/json" \ "https://$PORTAINER_URL/api/stacks/$STACK_ID/git/redeploy?endpointId=$ENDPOINT_ID")
-d '{"Prune": true}' \
https://$PORTAINER_URL/api/stacks/$STACK_ID/deploy 2>&1)
HTTP_CODE=$(echo "$RESPONSE" | grep "< HTTP/" | awk '{print $3}') # Extraire le code HTTP de la réponse
HTTP_CODE="${RESPONSE: -3}"
echo "Réponse de l'API :" BODY="${RESPONSE::-3}"
echo "$RESPONSE"
if [ "$HTTP_CODE" != "200" ]; then if [ "$HTTP_CODE" != "200" ]; then
echo "Erreur : Échec du déploiement. Code HTTP : $HTTP_CODE" echo "Erreur : Échec du déploiement. Code HTTP : $HTTP_CODE"
echo "Réponse de l'API : $BODY"
exit 1 exit 1
fi fi