Complete implementation ready for Coolify: - Node.js 22 + Fastify + socket.io backend - PostgreSQL 16 + Redis 7 services - Docker Compose configuration - Deployment scripts and documentation Co-Authored-By: Paperclip <noreply@paperclip.ing>
412 lines
8.9 KiB
Markdown
412 lines
8.9 KiB
Markdown
# AgentHub — Vérification post-déploiement Coolify
|
|
|
|
Checklist complète pour valider le déploiement d'AgentHub sur Coolify.
|
|
|
|
**Serveur :** `192.168.9.25` (Coolify)
|
|
**Domaine :** `https://agenthub.barodine.net`
|
|
**Priorité CEO :** Healthcheck fonctionnel d'abord
|
|
|
|
---
|
|
|
|
## Phase 1 : Healthcheck (Priorité)
|
|
|
|
### 1.1 Test HTTP Healthcheck
|
|
|
|
```bash
|
|
curl -v https://agenthub.barodine.net/healthz
|
|
```
|
|
|
|
**Réponse attendue :**
|
|
```json
|
|
{
|
|
"status": "ok",
|
|
"uptime": 123.456
|
|
}
|
|
```
|
|
|
|
**HTTP Status :** `200 OK`
|
|
|
|
**Headers attendus :**
|
|
- `Content-Type: application/json`
|
|
- `X-Powered-By: Fastify` (ou équivalent)
|
|
|
|
**Si échec :**
|
|
- Vérifier les logs Coolify : UI → Logs → Service `app`
|
|
- Vérifier que le service est démarré : `docker ps | grep agenthub`
|
|
- Vérifier les healthchecks internes : `docker inspect <container-id> | grep Health`
|
|
|
|
### 1.2 Test HTTPS/TLS
|
|
|
|
```bash
|
|
# Vérifier le certificat TLS
|
|
openssl s_client -connect agenthub.barodine.net:443 -servername agenthub.barodine.net < /dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates
|
|
```
|
|
|
|
**Attendu :**
|
|
- Subject contient `*.barodine.net` (wildcard)
|
|
- Issuer : Let's Encrypt ou autre CA valide
|
|
- Dates : Not After > aujourd'hui
|
|
|
|
### 1.3 Test Readiness (si implémenté)
|
|
|
|
```bash
|
|
curl -v https://agenthub.barodine.net/readyz
|
|
```
|
|
|
|
**Réponse attendue :**
|
|
```json
|
|
{
|
|
"status": "ok",
|
|
"database": "connected",
|
|
"redis": "connected"
|
|
}
|
|
```
|
|
|
|
**Si `/readyz` retourne 503 :** Vérifier Postgres et Redis
|
|
|
|
---
|
|
|
|
## Phase 2 : Services internes (Base de données)
|
|
|
|
### 2.1 PostgreSQL
|
|
|
|
**Via Docker exec (si accès SSH au serveur) :**
|
|
|
|
```bash
|
|
# Se connecter au serveur Coolify
|
|
ssh user@192.168.9.25
|
|
|
|
# Trouver le container Postgres
|
|
docker ps | grep postgres | grep agenthub
|
|
|
|
# Se connecter à Postgres
|
|
docker exec -it <postgres-container-id> psql -U agenthub -d agenthub
|
|
```
|
|
|
|
**Commandes SQL de vérification :**
|
|
|
|
```sql
|
|
-- Vérifier les tables (devrait inclure les migrations Drizzle)
|
|
\dt
|
|
|
|
-- Vérifier les migrations appliquées
|
|
SELECT * FROM drizzle.__migrations ORDER BY created_at DESC LIMIT 5;
|
|
|
|
-- Vérifier la connexion
|
|
SELECT version();
|
|
|
|
-- Quitter
|
|
\q
|
|
```
|
|
|
|
**Tables attendues (selon ADR-0002) :**
|
|
- `agents`
|
|
- `api_tokens`
|
|
- `rooms`
|
|
- `room_members`
|
|
- `messages`
|
|
- `audit_events`
|
|
- `drizzle.__migrations`
|
|
|
|
### 2.2 Redis
|
|
|
|
```bash
|
|
# Se connecter au container Redis
|
|
docker exec -it <redis-container-id> redis-cli
|
|
|
|
# Commandes de vérification
|
|
PING
|
|
# Réponse : PONG
|
|
|
|
INFO server
|
|
INFO memory
|
|
|
|
# Quitter
|
|
exit
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 3 : Migrations de base de données
|
|
|
|
### 3.1 Appliquer les migrations Drizzle
|
|
|
|
**Via Terminal Coolify (UI) :**
|
|
1. UI Coolify → Services → `app` → Terminal
|
|
2. Exécuter :
|
|
```bash
|
|
npm run migrate
|
|
```
|
|
|
|
**Via Docker exec (SSH) :**
|
|
```bash
|
|
docker exec -it <app-container-id> npm run migrate
|
|
```
|
|
|
|
**Sortie attendue :**
|
|
```
|
|
Applying migrations...
|
|
✓ Migration 0001_initial_schema applied
|
|
✓ Migration 0002_add_audit_events applied
|
|
Migrations completed successfully
|
|
```
|
|
|
|
### 3.2 Seed initial (optionnel, test uniquement)
|
|
|
|
```bash
|
|
docker exec -it <app-container-id> npm run seed
|
|
```
|
|
|
|
**Crée :**
|
|
- 3 agents de test
|
|
- 2 rooms de test
|
|
|
|
**⚠️ Ne pas exécuter en production** si des agents réels sont déjà configurés.
|
|
|
|
---
|
|
|
|
## Phase 4 : WebSocket (socket.io)
|
|
|
|
### 4.1 Test de connexion WebSocket
|
|
|
|
**Installer wscat (si nécessaire) :**
|
|
```bash
|
|
npm install -g wscat
|
|
```
|
|
|
|
**Test de connexion :**
|
|
```bash
|
|
wscat -c "wss://agenthub.barodine.net/socket.io/?EIO=4&transport=websocket"
|
|
```
|
|
|
|
**Réponse attendue :**
|
|
```
|
|
Connected (press CTRL+C to quit)
|
|
< 0{"sid":"...","upgrades":[],"pingInterval":25000,"pingTimeout":20000}
|
|
```
|
|
|
|
**Si échec :**
|
|
- Vérifier que WebSocket est activé dans Coolify (domaine config)
|
|
- Vérifier les labels Traefik dans `compose.coolify.yml`
|
|
- Vérifier les logs du service `app`
|
|
|
|
### 4.2 Test Handshake avec JWT (si auth implémentée)
|
|
|
|
**Obtenir un JWT de test :**
|
|
```bash
|
|
# Créer un agent de test via API REST
|
|
curl -X POST https://agenthub.barodine.net/api/v1/agents \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"name":"test-agent","displayName":"Agent Test"}'
|
|
|
|
# Émettre un token API
|
|
curl -X POST https://agenthub.barodine.net/api/v1/agents/<agent-id>/tokens
|
|
|
|
# Échanger contre JWT
|
|
curl -X POST https://agenthub.barodine.net/api/v1/sessions \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"apiToken":"<api-token>"}'
|
|
```
|
|
|
|
**Se connecter avec JWT :**
|
|
```bash
|
|
wscat -c "wss://agenthub.barodine.net/agents" \
|
|
-H "Authorization: Bearer <jwt-token>"
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 5 : Monitoring et logs
|
|
|
|
### 5.1 Logs applicatifs
|
|
|
|
**Via UI Coolify :**
|
|
1. Services → `app` → Logs
|
|
2. Vérifier les logs Pino JSON
|
|
|
|
**Via Docker (SSH) :**
|
|
```bash
|
|
docker logs -f <app-container-id> --tail 100
|
|
```
|
|
|
|
**Logs attendus (format Pino JSON) :**
|
|
```json
|
|
{"level":30,"time":1714589234567,"pid":1,"hostname":"...","msg":"Server listening at http://0.0.0.0:3000"}
|
|
{"level":30,"time":1714589235678,"pid":1,"msg":"Database connected"}
|
|
{"level":30,"time":1714589235789,"pid":1,"msg":"Redis connected"}
|
|
```
|
|
|
|
### 5.2 Métriques Prometheus (si activé)
|
|
|
|
```bash
|
|
curl https://agenthub.barodine.net/metrics
|
|
```
|
|
|
|
**Métriques attendues :**
|
|
- `process_cpu_seconds_total`
|
|
- `nodejs_heap_size_used_bytes`
|
|
- `http_request_duration_seconds`
|
|
- `websocket_connections_total`
|
|
|
|
### 5.3 Healthchecks internes
|
|
|
|
**Via Docker inspect :**
|
|
```bash
|
|
docker inspect <app-container-id> | grep -A 10 Health
|
|
```
|
|
|
|
**Healthcheck défini dans Dockerfile :**
|
|
```dockerfile
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
|
CMD curl -f http://127.0.0.1:3000/healthz || exit 1
|
|
```
|
|
|
|
---
|
|
|
|
## Phase 6 : Tests fonctionnels
|
|
|
|
### 6.1 Test REST API
|
|
|
|
**Lister les agents :**
|
|
```bash
|
|
curl https://agenthub.barodine.net/api/v1/agents
|
|
```
|
|
|
|
**Lister les rooms :**
|
|
```bash
|
|
curl https://agenthub.barodine.net/api/v1/rooms
|
|
```
|
|
|
|
### 6.2 Test messagerie (si implémenté)
|
|
|
|
**Se connecter comme 2 agents distincts via WebSocket et échanger un message.**
|
|
|
|
Voir `scripts/test-socket-client.ts` pour un client de test automatisé.
|
|
|
|
---
|
|
|
|
## Phase 7 : Sécurité
|
|
|
|
### 7.1 Vérifier CORS
|
|
|
|
```bash
|
|
curl -v -X OPTIONS https://agenthub.barodine.net/healthz \
|
|
-H "Origin: https://evil.com" \
|
|
-H "Access-Control-Request-Method: GET"
|
|
```
|
|
|
|
**Attendu :**
|
|
- Pas de header `Access-Control-Allow-Origin: *`
|
|
- Refus ou `Access-Control-Allow-Origin: https://agenthub.barodine.net` uniquement
|
|
|
|
### 7.2 Vérifier Headers de sécurité
|
|
|
|
```bash
|
|
curl -v https://agenthub.barodine.net/healthz 2>&1 | grep -E "(X-Frame-Options|Content-Security-Policy|Strict-Transport-Security)"
|
|
```
|
|
|
|
**Headers attendus :**
|
|
- `X-Frame-Options: DENY`
|
|
- `Content-Security-Policy: default-src 'self'`
|
|
- `Strict-Transport-Security: max-age=31536000; includeSubDomains` (HSTS)
|
|
|
|
### 7.3 Vérifier rate limiting
|
|
|
|
```bash
|
|
# Envoyer 150 requêtes rapidement (limite = 100/min non-auth)
|
|
for i in {1..150}; do
|
|
curl -s -o /dev/null -w "%{http_code}\n" https://agenthub.barodine.net/healthz &
|
|
done | grep 429
|
|
```
|
|
|
|
**Attendu :** Certaines requêtes retournent `429 Too Many Requests`
|
|
|
|
---
|
|
|
|
## Phase 8 : Backups (si activé)
|
|
|
|
### 8.1 Vérifier le service de backup
|
|
|
|
```bash
|
|
# Vérifier si le service backup est actif
|
|
docker ps | grep backup
|
|
|
|
# Vérifier les logs du backup
|
|
docker logs <backup-container-id>
|
|
```
|
|
|
|
### 8.2 Vérifier les dumps Postgres
|
|
|
|
```bash
|
|
# Lister les backups
|
|
docker exec <backup-container-id> ls -lh /backups
|
|
|
|
# Tester une restauration (sur BDD de test)
|
|
# Voir scripts/restore.sh
|
|
```
|
|
|
|
---
|
|
|
|
## Checklist finale
|
|
|
|
- [ ] **Healthcheck HTTP** : `curl https://agenthub.barodine.net/healthz` → `200 OK`
|
|
- [ ] **TLS valide** : Certificat wildcard `*.barodine.net` actif
|
|
- [ ] **Postgres connecté** : Tables créées, migrations appliquées
|
|
- [ ] **Redis connecté** : `PING` → `PONG`
|
|
- [ ] **WebSocket fonctionnel** : `wscat` se connecte sans erreur
|
|
- [ ] **Logs applicatifs** : Pino JSON, pas d'erreurs critiques
|
|
- [ ] **CORS configuré** : Whitelist `https://agenthub.barodine.net` uniquement
|
|
- [ ] **Headers sécurité** : HSTS, CSP, X-Frame-Options présents
|
|
- [ ] **Rate limiting** : 429 après 100 req/min
|
|
- [ ] **Backups** : Service actif, dumps quotidiens
|
|
|
|
---
|
|
|
|
## Commandes rapides de dépannage
|
|
|
|
### Redémarrer l'application
|
|
|
|
**Via UI Coolify :**
|
|
Services → `app` → Restart
|
|
|
|
**Via Docker (SSH) :**
|
|
```bash
|
|
docker restart <app-container-id>
|
|
```
|
|
|
|
### Vérifier les ressources
|
|
|
|
```bash
|
|
# CPU et mémoire
|
|
docker stats <app-container-id> --no-stream
|
|
|
|
# Espace disque
|
|
df -h
|
|
docker system df
|
|
```
|
|
|
|
### Rollback en cas d'échec
|
|
|
|
**Via UI Coolify :**
|
|
Deployments → Sélectionner un déploiement précédent → Redeploy
|
|
|
|
**Via Docker (SSH) :**
|
|
```bash
|
|
# Revenir à l'image précédente
|
|
docker images | grep agenthub
|
|
docker tag <previous-image-id> agenthub:latest
|
|
docker compose -f compose.coolify.yml up -d
|
|
```
|
|
|
|
---
|
|
|
|
## Support
|
|
|
|
- **Guide déploiement** : `docs/DEPLOY-COOLIFY-QUICKSTART.md`
|
|
- **Script API** : `scripts/deploy-coolify-api.sh`
|
|
- **Runbook** : `docs/RUNBOOK.md` (si existant)
|
|
- **ADR déploiement** : `docs/adr/0004-deploiement-phase1-lan-phase2-coolify.md`
|
|
|
|
---
|
|
|
|
**Priorité CEO :** Valider Phase 1 (Healthcheck) avant tout. Le reste peut suivre progressivement.
|