diff --git a/CLAUDE.md b/CLAUDE.md index c4987e3..e613894 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -82,15 +82,40 @@ Aucun service en erreur connu (vérifié 2026-02-19). `mail` tourne correctement Voir `todo.txt` (format todo.txt standard) +## Mettre à jour une app CapRover + +**TOUJOURS passer par l'API CapRover** — jamais via `docker service update` directement (CapRover ne le verrait pas). + +### Procédure + +1. **Login** (obtenir un token) : +```python +import urllib.request, json + +data = json.dumps({'password': 'CAPROVER_PASSWORD'}).encode() +req = urllib.request.Request('https://captain.cloud.sans.pub/api/v2/login', data=data, headers={'Content-Type': 'application/json'}, method='POST') +with urllib.request.urlopen(req) as r: + token = json.loads(r.read().decode())['data']['token'] +``` + +2. **Déployer une nouvelle image** : +```python +headers = {'Content-Type': 'application/json', 'x-captain-auth': token, 'x-namespace': 'captain'} +captain_def = json.dumps({'schemaVersion': 2, 'imageName': 'IMAGE:TAG'}) +payload = json.dumps({'appName': 'NOM_APP', 'captainDefinitionContent': captain_def, 'gitHash': ''}).encode() +req = urllib.request.Request('https://captain.cloud.sans.pub/api/v2/user/apps/appData/NOM_APP', data=payload, headers=headers, method='POST') +with urllib.request.urlopen(req) as r: + print(r.read().decode()) # {"status":100,"description":"Deploy is done"} +``` + +> Note : `curl` a un problème d'encodage dans cet environnement — utiliser `python3` à la place. + ## Commandes utiles ```bash # Voir les logs d'un service ssh cloud@sans.pub "docker service logs srv-captain--NOM --tail 100" -# Redémarrer un service -ssh cloud@sans.pub "docker service update --force srv-captain--NOM" - # Espace disque des volumes ssh cloud@sans.pub "docker system df -v"