ProbatioVault - Architecture Infrastructure Complète¶
Vue d'ensemble¶
Ce document décrit l'architecture complète de l'infrastructure ProbatioVault, de l'environnement de développement jusqu'à la production.
Architecture par environnement¶
1. Environnement DEV (12GB RAM, 6 vCores)¶
VPS unique : probatiovault-dev (51.68.126.160)
Composants installés : - ✅ GitLab Runner (Docker executor) - ✅ SonarQube + PostgreSQL dédié (Docker Compose) - ✅ PostgreSQL (mode local - même VPS que l'app) - ✅ Application ProbatioVault - ✅ Docker & Docker Compose - ✅ Node.js 20 LTS - ✅ Nginx (reverse proxy) - ✅ Security (UFW, fail2ban)
Rôle : - Développement et tests locaux - CI/CD complet (build, test, lint, quality gate) - Déploiement automatique sur dev - Point de départ pour déploiements SSH vers test/prod
Configuration Terraform : environments/dev.tfvars
install_gitlab_runner = true
install_sonarqube = true
install_postgresql = true
postgresql_mode = "local"
2. Environnement TEST (4-8GB RAM recommandé)¶
VPS unique : probatiovault-test
Composants installés : - ❌ GitLab Runner (déploiement via SSH depuis dev) - ❌ SonarQube (pas nécessaire) - ✅ PostgreSQL (mode local - même VPS que l'app) - ✅ Application ProbatioVault - ✅ Docker & Docker Compose - ✅ Node.js 20 LTS - ✅ Nginx (reverse proxy) - ✅ Security (UFW, fail2ban)
Rôle : - Tests d'intégration et d'acceptation - Validation avant mise en production - Environnement stable pour démos
Déploiement : - Manuel via GitLab CI/CD - SSH depuis runner dev - Pas de runner local
Configuration Terraform : environments/test.tfvars
install_gitlab_runner = false
install_sonarqube = false
install_postgresql = true
postgresql_mode = "local"
3. Environnement PRODUCTION (Architecture haute disponibilité)¶
3.1 VPS Runner PROD (2-4GB RAM)¶
VPS dédié : probatiovault-runner-prod
Composants installés : - ✅ GitLab Runner uniquement (isolation sécurité) - ✅ Docker (pour executor) - ✅ Security (UFW, fail2ban)
Rôle : - Isolation sécurité pour déploiements production - Pas d'accès direct à la base de données - Déploiement SSH vers VPS PROD
Configuration Terraform : environments/prod-runner.tfvars
3.2 VPS Application PROD (4-8GB RAM)¶
VPS dédié : probatiovault-prod
Composants installés : - ❌ GitLab Runner - ❌ SonarQube - ❌ PostgreSQL (base externe) - ✅ Application ProbatioVault - ✅ Docker & Docker Compose - ✅ Node.js 20 LTS - ✅ Nginx (reverse proxy + SSL) - ✅ Security (UFW, fail2ban)
Rôle : - Hébergement application production - Connexion à base de données externe - Haute disponibilité
Configuration Terraform : environments/prod.tfvars
install_gitlab_runner = false
install_sonarqube = false
install_postgresql = false
postgresql_mode = "remote"
3.3 VPS Base de données PROD (4-8GB RAM)¶
VPS dédié : probatiovault-db-prod
Composants installés : - ❌ GitLab Runner - ❌ SonarQube - ✅ PostgreSQL (mode dedicated) - ✅ Backups automatiques - ✅ Security (UFW, fail2ban) - ✅ Monitoring
Rôle : - Base de données production isolée - Backups quotidiens avec rétention 30 jours - Performance optimisée pour PostgreSQL
Configuration Terraform : environments/prod-db.tfvars
install_gitlab_runner = false
install_sonarqube = false
install_postgresql = true
postgresql_mode = "dedicated"
postgresql_allowed_ips = ["<IP_VPS_PROD>"]
Résumé Architecture Complète¶
┌─────────────────────────────────────────────────────────────────┐
│ DÉVELOPPEMENT (DEV) │
│ VPS 12GB - 6 vCores │
│ 51.68.126.160 │
├─────────────────────────────────────────────────────────────────┤
│ • GitLab Runner (CI/CD complet) │
│ • SonarQube + PostgreSQL SQ (Quality Gate) │
│ • PostgreSQL App (mode local) │
│ • Application ProbatioVault │
│ • Docker + Node.js 20 + Nginx │
│ │
│ Déploiement: Automatique via CI/CD │
└─────────────────────────────────────────────────────────────────┘
│
│ SSH Deploy
▼
┌─────────────────────────────────────────────────────────────────┐
│ TEST │
│ VPS 4-8GB │
├─────────────────────────────────────────────────────────────────┤
│ • PostgreSQL (mode local) │
│ • Application ProbatioVault │
│ • Docker + Node.js 20 + Nginx │
│ │
│ Déploiement: Manuel via SSH depuis runner dev │
└─────────────────────────────────────────────────────────────────┘
│
│ Manuel avec validation
▼
┌─────────────────────────────────────────────────────────────────┐
│ PRODUCTION (5 VPS) │
└─────────────────────────────────────────────────────────────────┘
┌──────────────────────┐ ┌──────────────────────┐
│ Runner PROD │ │ Application PROD │
│ VPS 2-4GB │──SSH─▶│ VPS 4-8GB │
│ │ │ │
│ • GitLab Runner │ │ • App ProbatioVault │
│ • Docker │ │ • Node.js 20 │
│ │ │ • Nginx + SSL │
└──────────────────────┘ └──────────┬───────────┘
│
│ TCP/5432
▼
┌──────────────────────┐
│ Base de données │
│ VPS 4-8GB │
│ │
│ • PostgreSQL │
│ • Backups auto │
│ • Monitoring │
└──────────────────────┘
Flux de déploiement¶
Développement → Test → Production¶
1. DEV
├─ git push → GitLab
├─ Runner DEV exécute pipeline:
│ ├─ npm install
│ ├─ npm run lint
│ ├─ npm test
│ ├─ SonarQube analysis (Quality Gate)
│ └─ Deploy automatique sur VPS DEV
└─ ✅ Application déployée sur DEV
2. TEST (Manuel)
├─ Click "Deploy to TEST" dans GitLab
├─ Runner DEV → SSH → VPS TEST
│ ├─ Pull code
│ ├─ npm install
│ ├─ Build production
│ └─ PM2 restart
└─ ✅ Application déployée sur TEST
3. PRODUCTION (Manuel + Tag)
├─ git tag v1.0.0 && git push --tags
├─ Click "Deploy to PROD" dans GitLab
├─ Runner PROD → SSH → VPS PROD
│ ├─ Pull code (tag spécifique)
│ ├─ npm install (mode production)
│ ├─ Build production optimisé
│ └─ PM2 restart (zero downtime)
└─ ✅ Application déployée sur PROD
Configuration PostgreSQL par environnement¶
DEV : Mode local¶
→ App et BDD sur même VPS, connexion locale rapide TEST : Mode local¶
→ Configuration identique à DEV pour cohérence PROD : Mode remote + VPS dédié BDD¶
# VPS Application PROD
postgresql_mode: "remote"
postgresql_host: "<IP_VPS_BDD_PROD>"
postgresql_port: 5432
# VPS BDD PROD
postgresql_mode: "dedicated"
listen_addresses: "*"
max_connections: 200
shared_buffers: "1GB"
effective_cache_size: "3GB"
postgresql_allowed_ips:
- "<IP_VPS_PROD>"
SonarQube Configuration¶
Installation : Uniquement sur VPS DEV
Accès : http://51.68.126.160:9000
Credentials par défaut : - Username: admin - Password: admin (à changer lors de la première connexion)
Intégration GitLab CI :
sonarqube:
stage: quality
image: sonarsource/sonar-scanner-cli:latest
variables:
SONAR_HOST_URL: "http://51.68.126.160:9000"
SONAR_TOKEN: $SONAR_TOKEN
script:
- sonar-scanner
only:
- dev
Base de données : PostgreSQL dédié dans Docker Compose
Persistance : - /opt/sonarqube/data - /opt/sonarqube/logs - /opt/sonarqube/extensions
Variables GitLab CI/CD requises¶
Voir GITLAB_VARIABLES.md pour la liste complète.
Variables essentielles : - SSH_PRIVATE_KEY_DEV, SSH_PRIVATE_KEY_TEST, SSH_PRIVATE_KEY_PROD - SONAR_TOKEN - DB_PASSWORD_DEV, DB_PASSWORD_TEST, DB_PASSWORD_PROD
Sécurité¶
Firewall (UFW)¶
Règles communes :
VPS DEV :
VPS BDD PROD :
Fail2ban¶
Protection contre brute force SSH : - Max 5 tentatives en 10 minutes - Ban 1 heure
SSL/TLS¶
Recommandation : Utiliser Certbot (Let's Encrypt)
Monitoring et Backups¶
PostgreSQL Backups¶
Configuration : - Backups quotidiens automatiques (cron) - Rétention : 7 jours (DEV/TEST), 30 jours (PROD) - Format : SQL compressé (gzip) - Emplacement : /var/backups/postgresql/
Script : /usr/local/bin/backup-postgresql.sh
Restauration :
Logs¶
Localisation : - Application : /opt/probatiovault/logs/ - Nginx : /var/log/nginx/ - PostgreSQL : /var/log/postgresql/ - GitLab Runner : /var/log/gitlab-runner/
Maintenance¶
Mises à jour système¶
Automatique (sécurité) :
Manuel (applications) :
# Mise à jour Node.js, Docker, etc.
ansible-playbook -i inventory/dev/hosts.ini playbook.yml --tags common
Rotation des secrets¶
Recommandation : Rotation trimestrielle - Mots de passe PostgreSQL - Tokens GitLab - Clés SSH (si compromission)
Évolution et Scalabilité¶
Phase 1 (Actuelle) : 1 VPS DEV¶
- ✅ Développement
- ✅ CI/CD
- ✅ Quality Gate
Phase 2 : + 1 VPS TEST¶
- ✅ Tests d'intégration
- ✅ Validation pré-production
Phase 3 : Production complète (3 VPS)¶
- ✅ Runner PROD isolé
- ✅ Application PROD
- ✅ BDD PROD dédiée
Phase 4 (Future) : Haute disponibilité¶
- Load balancer (HAProxy/Nginx)
- Réplication PostgreSQL (Master/Slave)
- Monitoring avancé (Prometheus/Grafana)
- CDN pour assets statiques
Coûts estimés¶
| Environnement | VPS | Specs | Coût/mois (OVH) |
|---|---|---|---|
| DEV | 1x VPS-2 | 6 vCores, 12GB | ~20€ |
| TEST | 1x VPS-1 | 2-4 vCores, 4-8GB | ~10€ |
| PROD Runner | 1x VPS-1 | 2 vCores, 4GB | ~10€ |
| PROD App | 1x VPS-1 | 4 vCores, 8GB | ~15€ |
| PROD BDD | 1x VPS-1 | 4 vCores, 8GB | ~15€ |
| TOTAL PROD | ~70€/mois |
Contacts et Support¶
Documentation : - Terraform : terraform/ - Ansible : ansible/ - CI/CD : GITLAB_CI_EXAMPLE.yml - Variables : GITLAB_VARIABLES.md
Commandes utiles : - Voir DEPLOYMENT_STRATEGY.md