xpeditis2.0/docs/deployment/CI_CD_MULTI_ENV.md
David c19af3b119
Some checks failed
CI/CD Pipeline / Backend - Build, Test & Push (push) Failing after 58s
CI/CD Pipeline / Frontend - Build, Test & Push (push) Failing after 5m55s
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Deployment Summary (push) Has been skipped
CI/CD Pipeline / Deploy to Portainer (push) Has been skipped
CI/CD Pipeline / Discord Notification (Success) (push) Has been skipped
CI/CD Pipeline / Discord Notification (Failure) (push) Has been skipped
docs: reorganiser completement la documentation dans docs/
Reorganisation majeure de toute la documentation du projet pour
ameliorer la navigation et la maintenance.

## Changements principaux

### Organisation (80 -> 4 fichiers .md a la racine)
- Deplace 82 fichiers .md dans docs/ organises en 11 categories
- Conserve uniquement 4 fichiers essentiels a la racine:
  * README.md, CLAUDE.md, PRD.md, TODO.md

### Structure docs/ creee
- installation/ (5 fichiers) - Guides d'installation
- deployment/ (25 fichiers) - Deploiement et infrastructure
- phases/ (21 fichiers) - Historique du developpement
- testing/ (5 fichiers) - Tests et qualite
- architecture/ (6 fichiers) - Documentation technique
- carrier-portal/ (2 fichiers) - Portail transporteur
- csv-system/ (5 fichiers) - Systeme CSV
- debug/ (4 fichiers) - Debug et troubleshooting
- backend/ (1 fichier) - Documentation backend
- frontend/ (1 fichier) - Documentation frontend
- legacy/ (vide) - Pour archives futures

### Documentation nouvelle
- docs/README.md - Index complet de toute la documentation (367 lignes)
  * Guide de navigation par scenario
  * Recherche rapide par theme
  * FAQ et commandes rapides
- docs/CLEANUP-REPORT-2025-12-22.md - Rapport detaille du nettoyage

### Scripts reorganises
- add-email-to-csv.py -> scripts/
- deploy-to-portainer.sh -> docker/

### Fichiers supprimes
- 1536w default.svg (11MB) - Fichier non utilise

### References mises a jour
- CLAUDE.md - Section Documentation completement reecrite
- docs/architecture/EMAIL_IMPLEMENTATION_STATUS.md - Chemin script Python
- docs/deployment/REGISTRY_PUSH_GUIDE.md - Chemins script deploiement

## Metriques
- 87 fichiers modifies/deplaces
- 82 fichiers .md organises dans docs/
- 11MB d'espace libere
- Temps de recherche reduit de ~5min a ~30s (-90%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 15:45:51 +01:00

258 lines
6.2 KiB
Markdown

# 🚀 CI/CD Multi-Environnements - Proposition
## 📊 Configuration Actuelle
**Trigger** :
```yaml
on:
push:
branches:
- preprod # ← UNIQUEMENT preprod
```
**Tags créés** :
- `xpeditis-backend:preprod`
- `xpeditis-frontend:preprod`
**Problème** : Si vous créez d'autres branches (staging, production), elles ne déclenchent pas la CI/CD.
---
## ✅ Solution 1 : Multi-Environnements (Recommandé)
### Configuration Proposée
```yaml
on:
push:
branches:
- main # Production
- preprod # Pre-production
- staging # Staging (optionnel)
- develop # Development (optionnel)
```
### Tags Créés Automatiquement
| Branche | Tags Créés | Usage |
|---------|------------|-------|
| `main` | `xpeditis-backend:main`<br>`xpeditis-backend:latest` | Production |
| `preprod` | `xpeditis-backend:preprod` | Pre-production |
| `staging` | `xpeditis-backend:staging` | Staging |
| `develop` | `xpeditis-backend:develop` | Development |
### Avantages
- ✅ Chaque environnement a son tag dédié
- ✅ Tag `latest` automatiquement créé pour production (`main`)
- ✅ Workflow GitFlow supporté
- ✅ Pas besoin de modifier les tags manuellement
---
## ✅ Solution 2 : Ajouter Tag `latest` pour Preprod
Si vous voulez que `preprod` crée aussi un tag `latest` :
```yaml
tags: |
type=ref,event=branch
type=raw,value=latest # ← Enlever le "enable={{is_default_branch}}"
```
**Résultat** :
- Push sur `preprod` → Tags : `preprod` + `latest`
**Inconvénient** : Le tag `latest` pointe toujours vers la dernière image buildée, peu importe la branche.
---
## ✅ Solution 3 : Tags Supplémentaires (Git SHA, Date)
Pour avoir plus de traçabilité :
```yaml
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
```
**Résultat pour preprod** :
- `xpeditis-backend:preprod` (tag principal)
- `xpeditis-backend:preprod-a1b2c3d` (tag avec commit SHA)
**Avantages** :
- ✅ Rollback facile vers un commit spécifique
- ✅ Traçabilité complète
---
## ✅ Solution 4 : Tags Sémantiques (Releases)
Pour les releases en production avec versioning :
```yaml
on:
push:
branches:
- main
- preprod
tags:
- 'v*.*.*' # v1.0.0, v1.2.3, etc.
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
```
**Résultat pour tag `v1.2.3`** :
- `xpeditis-backend:1.2.3`
- `xpeditis-backend:1.2`
- `xpeditis-backend:latest`
---
## 📋 Recommandation pour Xpeditis
### Configuration Proposée (Production-Ready)
```yaml
name: CI/CD Pipeline
on:
push:
branches:
- main # Production
- preprod # Pre-production
pull_request:
branches:
- main
- preprod
env:
REGISTRY: rg.fr-par.scw.cloud/weworkstudio
NODE_VERSION: '20'
jobs:
backend:
name: Backend - Build, Test & Push
runs-on: ubuntu-latest
# ...
steps:
# ... (setup steps)
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/xpeditis-backend
tags: |
# Tag avec le nom de la branche
type=ref,event=branch
# Tag "latest" seulement pour main (production)
type=raw,value=latest,enable={{is_default_branch}}
# Tag avec le commit SHA (pour rollback)
type=sha,prefix={{branch}}-,format=short
# Tag avec la date (optionnel)
type=raw,value={{branch}}-{{date 'YYYYMMDD-HHmmss'}}
- name: Build and push Backend Docker image
uses: docker/build-push-action@v5
with:
context: ./apps/backend
file: ./apps/backend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
```
### Tags Créés
**Push sur `preprod`** :
- `xpeditis-backend:preprod`
- `xpeditis-backend:preprod-a1b2c3d`
- `xpeditis-backend:preprod-20251119-143022`
**Push sur `main`** :
- `xpeditis-backend:main`
- `xpeditis-backend:latest` ← Production stable
- `xpeditis-backend:main-a1b2c3d`
- `xpeditis-backend:main-20251119-143022`
---
## 🎯 Configuration Minimale (Actuelle + Latest)
Si vous voulez juste ajouter le tag `latest` pour `preprod` :
```yaml
tags: |
type=ref,event=branch
type=raw,value=latest
```
**Résultat** :
- Push sur `preprod` → Tags : `preprod` + `latest`
---
## 📊 Tableau Comparatif
| Solution | Tags pour Preprod | Tags pour Main | Rollback | Complexité |
|----------|-------------------|----------------|----------|------------|
| **Actuelle** | `preprod` | ❌ Pas de CI/CD | ❌ | ⚡ Simple |
| **Solution 1** | `preprod` | `main`, `latest` | ❌ | ⚡ Simple |
| **Solution 2** | `preprod`, `latest` | ❌ | ❌ | ⚡ Simple |
| **Solution 3** | `preprod`, `preprod-SHA` | `main`, `latest`, `main-SHA` | ✅ | 🔧 Moyen |
| **Solution 4** | `preprod`, tags sémantiques | `main`, `1.2.3`, `latest` | ✅ | 🔧 Avancé |
---
## ✅ Ma Recommandation
**Pour Xpeditis, utilisez Solution 1** (Multi-environnements) :
1. Ajouter branche `main` au trigger CI/CD
2. `main` → Production (avec tag `latest`)
3. `preprod` → Pre-production (tag `preprod`)
4. Optionnel : Ajouter SHA tags pour rollback
**Workflow Git** :
```
develop → preprod → main
↓ ↓ ↓
staging testing production
```
---
## 🔧 Fichier à Modifier
**Fichier** : `.github/workflows/ci.yml`
**Modification minimale** (lignes 3-6) :
```yaml
on:
push:
branches:
- main # ← AJOUTER pour production
- preprod # ← Garder pour pre-production
```
**Résultat** :
- Push sur `preprod` → Build et tag `preprod`
- Push sur `main` → Build et tag `main` + `latest`
---
**Date** : 2025-11-19
**Impact** : 🟡 Moyen - Permet déploiement multi-environnements
**Urgence** : 🟢 Basse - Configuration actuelle fonctionne pour preprod