Environnements
PCH-SIG est deploye sur trois environnements distincts avec des configurations specifiques.
Vue d'Ensemble
Comparaison des Environnements
| Caracteristique | Developpement | Preprod | Production |
|---|---|---|---|
| URL | localhost | 51.75.77.220 | serveur-production |
| Hebergement | Local | OVH Cloud | On-premise |
| Docker | Non (PHP natif) | Docker Compose | Docker Toolbox |
| Base de donnees | PostgreSQL local | PostgreSQL Docker | PostgreSQL Docker |
| Monitoring | Grafana local | Exporters | Exporters + Grafana |
| Badge UI | LOCAL (orange) | PREPROD (bleu) | Aucun |
| Branche Git | develop | staging | main |
Developpement Local
Configuration
| Service | Port | Description |
|---|---|---|
| Frontend | 3000 | React dev server |
| Backend | 8000 | PHP built-in server |
| PostgreSQL | 5432 | Base de donnees locale |
| Redis | 6379 | Cache local |
| Mailpit | 8025 | Emails de test (optionnel) |
Variables d'environnement
Frontend (.env.development.local) :
REACT_APP_API_URL=http://localhost:8000/api
REACT_APP_ENV_NAME=LOCAL
REACT_APP_ENV_COLOR=#f59e0b
Backend (.env.local) :
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/pch_sig"
REDIS_URL="redis://localhost:6379"
MAILER_DSN=smtp://localhost:1025
Badge d'environnement
Un badge orange LOCAL s'affiche en bas a gauche de l'ecran.
Preprod (Staging)
Serveur
| Parametre | Valeur |
|---|---|
| IP | 51.75.77.220 |
| Fournisseur | OVH Cloud |
| OS | Ubuntu 22.04 |
| Docker | Docker Compose natif |
Conteneurs Docker
┌─────────────────────────────────────────────────────────┐
│ pch_network │
├─────────────────────────────────────────────────────────┤
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ frontend │ │ nginx │ │ backend │ │
│ │ :80 │ │ :8000 │ │ php-fpm │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ postgres │ │ redis │ │ mailpit │ │
│ │ :5432 │ │ :6379 │ │ :8025 │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ cadvisor │ │ node │ │ loki │ │
│ │ :8080 │ │ :9100 │ │ :3100 │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────┘
Acces SSH
ssh ubuntu@51.75.77.220
Deploiement
# Connexion SSH
ssh ubuntu@51.75.77.220
# Mise a jour du code
cd /home/ubuntu/pch-sig
git pull origin staging
# Rebuild et restart
docker compose down
docker compose up -d --build
# Migrations
docker exec -it pch_backend php bin/console doctrine:migrations:migrate --no-interaction
Variables d'environnement
Frontend (.env.preprod) :
REACT_APP_API_URL=/api
REACT_APP_ENV_NAME=PREPROD
REACT_APP_ENV_COLOR=#3b82f6
Badge d'environnement
Un badge bleu PREPROD s'affiche en bas a gauche de l'ecran.
Production
Serveur
| Parametre | Valeur |
|---|---|
| IP | serveur-production |
| OS | Windows Server |
| Docker | Docker Toolbox + VirtualBox |
| VM Docker | 192.168.99.100 |
| Chemin projet | C:\pch-sig |
Architecture
┌────────────────────────────────────────────────────────────┐
│ Windows Server serveur-production │
├────────────────────────────────────────────────────────────┤
│ netsh portproxy │
│ :3000 → 192.168.99.100:80 │
│ :8000 → 192.168.99.100:8000 │
│ :8025 → 192.168.99.100:8025 │
│ :3001 → 192.168.99.100:3001 │
├────────────────────────────────────────────────────────────┤
│ VirtualBox VM (Docker Machine) │
│ 192.168.99.100 │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ pch_frontend │ pch_nginx │ pch_backend │ │
│ │ pch_postgres │ pch_redis │ pch_mailpit │ │
│ │ pch_grafana │ exporters │ │ │
│ └─────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────┘
Acces
$cred = Get-Credential # AdminREDISSEII / Admin1REDISSEIInetwork1
Enter-PSSession -ComputerName serveur-production -Credential $cred
Deploiement
Voir Deploiement Serveur pour les instructions detaillees.
Variables d'environnement
Frontend (.env.production) :
REACT_APP_API_URL=/api
# Pas de REACT_APP_ENV_NAME = pas de badge
Pas de badge
En production, aucun badge d'environnement ne s'affiche.
Git Flow
develop ──────> staging ──────> main
│ │ │
│ │ │
▼ ▼ ▼
LOCAL PREPROD PRODUCTION
Branches
| Branche | Environnement | Protection |
|---|---|---|
develop | Developpement | Non |
staging | Preprod | Merge depuis develop |
main | Production | Merge depuis staging |
Workflow de deploiement
- Developpement : Commits sur
develop - Tests preprod : Merge
develop→staging, deployer sur preprod - Validation : Tests sur preprod
- Production : Merge
staging→main, deployer sur prod
Monitoring
Architecture
Le monitoring est centralise sur la machine de developpement locale :
| Composant | Localisation | Fonction |
|---|---|---|
| Grafana | localhost:3001 | Dashboards |
| Prometheus | localhost:9090 | Collecte metriques |
| Loki | Preprod :3100 | Agregation logs |
Exporters sur les serveurs
| Exporter | Port | Metriques |
|---|---|---|
| cAdvisor | 8080 | Conteneurs Docker |
| Node Exporter | 9100 | Systeme OS |
| PostgreSQL Exporter | 9187 | Base de donnees |
| Redis Exporter | 9121 | Cache Redis |
| Promtail | - | Logs vers Loki |
Configuration Prometheus
scrape_configs:
- job_name: 'cadvisor'
static_configs:
- targets: ['51.75.77.220:8080'] # Preprod
- targets: ['serveur-production:8080'] # Prod
- job_name: 'node'
static_configs:
- targets: ['51.75.77.220:9100']
- targets: ['serveur-production:9100']
URLs de Test
Developpement
| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| API | http://localhost:8000/api |
| Mailpit | http://localhost:8025 |
Preprod
| Service | URL |
|---|---|
| Frontend | http://51.75.77.220 |
| API | http://51.75.77.220:8000/api |
| Mailpit | http://51.75.77.220:8025 |
| Loki | http://51.75.77.220:3100 |
Production
| Service | URL |
|---|---|
| Frontend | https://sig.ucp-pch.org |
| API | https://sig.ucp-pch.org/api |
| Mailpit | http://localhost:8025 |
| Grafana | http://localhost:3001 |
Utilisateurs de Test
| Role | Environnement | |
|---|---|---|
| makhtar.gueye@axone-sn.com | Admin | Tous |
| mrualopez@outlook.com | Utilisateur | Tous |