Pular para o conteúdo principal

Environnements

PCH-SIG est deploye sur trois environnements distincts avec des configurations specifiques.

Vue d'Ensemble

Architecture des Environnements

Comparaison des Environnements

CaracteristiqueDeveloppementPreprodProduction
URLlocalhost51.75.77.220serveur-production
HebergementLocalOVH CloudOn-premise
DockerNon (PHP natif)Docker ComposeDocker Toolbox
Base de donneesPostgreSQL localPostgreSQL DockerPostgreSQL Docker
MonitoringGrafana localExportersExporters + Grafana
Badge UILOCAL (orange)PREPROD (bleu)Aucun
Branche Gitdevelopstagingmain

Developpement Local

Configuration

ServicePortDescription
Frontend3000React dev server
Backend8000PHP built-in server
PostgreSQL5432Base de donnees locale
Redis6379Cache local
Mailpit8025Emails 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

ParametreValeur
IP51.75.77.220
FournisseurOVH Cloud
OSUbuntu 22.04
DockerDocker 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

ParametreValeur
IPserveur-production
OSWindows Server
DockerDocker Toolbox + VirtualBox
VM Docker192.168.99.100
Chemin projetC:\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

BrancheEnvironnementProtection
developDeveloppementNon
stagingPreprodMerge depuis develop
mainProductionMerge depuis staging

Workflow de deploiement

  1. Developpement : Commits sur develop
  2. Tests preprod : Merge developstaging, deployer sur preprod
  3. Validation : Tests sur preprod
  4. Production : Merge stagingmain, deployer sur prod

Monitoring

Architecture

Le monitoring est centralise sur la machine de developpement locale :

ComposantLocalisationFonction
Grafanalocalhost:3001Dashboards
Prometheuslocalhost:9090Collecte metriques
LokiPreprod :3100Agregation logs

Exporters sur les serveurs

ExporterPortMetriques
cAdvisor8080Conteneurs Docker
Node Exporter9100Systeme OS
PostgreSQL Exporter9187Base de donnees
Redis Exporter9121Cache 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

ServiceURL
Frontendhttp://localhost:3000
APIhttp://localhost:8000/api
Mailpithttp://localhost:8025

Preprod

ServiceURL
Frontendhttp://51.75.77.220
APIhttp://51.75.77.220:8000/api
Mailpithttp://51.75.77.220:8025
Lokihttp://51.75.77.220:3100

Production

ServiceURL
Frontendhttps://sig.ucp-pch.org
APIhttps://sig.ucp-pch.org/api
Mailpithttp://localhost:8025
Grafanahttp://localhost:3001

Utilisateurs de Test

EmailRoleEnvironnement
makhtar.gueye@axone-sn.comAdminTous
mrualopez@outlook.comUtilisateurTous

Prochaines Etapes