Date de création: 20/01/2026 Status: Phases 1-6 terminées, Phase 7+ à faire
Système de déploiement hybride combinant GitLab CI/CD avec des scripts bash modulaires pour supporter plusieurs stratégies de déploiement (Docker, Files, Remote).
┌─────────────────────────────────────────────────────────────────┐
│ SMART-DEPLOY SYSTEM │
├─────────────────────────────────────────────────────────────────┤
│ │
│ git push → GitLab CI → Runner → smart-deploy.sh │
│ │ │
│ ┌──────────────────┼──────────────────┐ │
│ ▼ ▼ ▼ │
│ [docker.sh] [files.sh] [remote.sh] │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ prod-portainer nginx/pve o2switch │
│ │
└─────────────────────────────────────────────────────────────────┘
ci-templates sur GitLabdeploy.yml - Template réutilisable/stock_8to/33800-stack/scripts/deploy/
├── smart-deploy.sh # Script principal
├── machines-registry.json # Registre des machines cibles
├── lib/
│ ├── common.sh # Fonctions utilitaires (log_*, require_var)
│ ├── parse-yaml.sh # Parser YAML pour conf.gouroubleu.yml
│ ├── targets.sh # Résolution des targets
│ └── services.sh # Injection variables de services
├── strategies/
│ ├── docker.sh # Déploiement Docker
│ ├── files.sh # Déploiement fichiers (releases)
│ └── remote.sh # Déploiement distant (rsync/git)
└── templates/
└── ... # Templates Dockerfile et nginx
{
"machines": {
"prod-portainer": { "type": "docker", "ip": "192.168.1.12" },
"nginx": { "type": "files", "ip": "192.168.1.104" },
"o2switch": { "type": "remote", "host": "yellow.o2switch.net", "ssh_alias": "o2switch" }
}
}
/stock_8to/33800-stack/scripts/deploy/templates/
├── Dockerfile.node # Node.js
├── Dockerfile.bun # Bun runtime
├── Dockerfile.python # Python
├── Dockerfile.rust # Rust
├── Dockerfile.static # Sites statiques
├── Dockerfile.qwik # Qwik SSR
└── Dockerfile.next # Next.js
Injection automatique des variables d'environnement selon les services déclarés.
# conf.gouroubleu.yml
services:
- supabase
- redis
- ntfy
| Service | Variables |
|---|---|
| supabase | DATABASE_URL, SUPABASE_URL, SUPABASE_ANON_KEY |
| redis | REDIS_URL |
| ntfy | NTFY_URL, NTFY_TOPIC |
| ai | ORCHESTRATOR_URL, WIN11_HOST |
| monitoring | GRAFANA_URL, PROMETHEUS_URL, LOKI_URL |
| gitlab | GITLAB_URL, GITLAB_TOKEN |
templates/
├── nginx-api.conf.template # API avec rate limiting
├── nginx-websocket.conf.template # WebSocket support
└── nginx-static.conf.template # SPA/sites statiques
Structure créée sur le serveur :
/opt/33800-services/mon-app/
├── releases/
│ ├── 2026-01-20_12-00-00-abc1234/
│ └── 2026-01-20_13-00-00-def5678/
├── shared/
│ ├── logs/
│ ├── data/
│ └── config/
└── current -> releases/2026-01-20_13-00-00-def5678
Fonctionnalités :
Pour hébergeurs mutualisés (O2switch) :
Notifications push via ntfy :
notify_deploy_start "app" "target"
notify_deploy_success "app" "target" "commit" "duration"
notify_deploy_failure "app" "target" "error"
notify_rollback "app" "target"
Registre JSON des services :
/stock_8to/33800-stack/monitoring/services-registry.jsonScript standalone :
./rollback.sh conf.gouroubleu.yml [steps]
name: "mon-api"
target: "prod-portainer" # ou nginx, o2switch, pve
type: "node" # node, bun, python, rust, static
domain: "api.33800.nowhere84.com"
port: 3000
# Services à injecter
services:
- supabase
- redis
- ntfy
# Stratégie files
strategy: "files"
shared: "logs data"
keep_releases: 5
# Stratégie remote
deploy:
method: rsync # rsync ou git
dest: "mon-api"
backup: true
pre_deploy: "npm install"
post_deploy: "pm2 restart"
# Nginx
nginx:
enabled: true
ssl: true
websocket: false
# Logs
logs:
enabled: true
driver: loki
# Via CI/CD (automatique sur push)
git push origin main
# Manuel
cd /path/to/project
DEPLOY_CONFIG=conf.gouroubleu.yml /stock_8to/33800-stack/scripts/deploy/smart-deploy.sh
# Files (1 version en arrière)
/stock_8to/33800-stack/scripts/deploy/rollback.sh conf.gouroubleu.yml 1
# Files (2 versions)
/stock_8to/33800-stack/scripts/deploy/rollback.sh conf.gouroubleu.yml 2
# Lister services
source /stock_8to/33800-stack/scripts/deploy/lib/common.sh
source /stock_8to/33800-stack/scripts/deploy/lib/registry.sh
registry_list_services
# Voir JSON
cat /stock_8to/33800-stack/monitoring/services-registry.json | jq .
| Target | Type | IP/Host | Usage |
|---|---|---|---|
| prod-portainer | docker | 192.168.1.12 | Containers PROD |
| dev-portainer | docker | 192.168.1.51 | Containers DEV |
| nginx | files | 192.168.1.104 | Sites statiques, apps Node |
| pve | files | 192.168.1.4 | Scripts, services locaux |
| o2switch | remote | yellow.o2switch.net | Dashboard, sites externes |
| win11 | files | 192.168.1.30 | Apps Windows |
| gitlab | files | 192.168.1.196 | Services GitLab |
| Test | Target | Status |
|---|---|---|
| Docker build + deploy | prod-portainer | ✅ |
| Files deploy | nginx | ✅ |
| Files rollback | nginx | ✅ |
| Remote rsync + backup | o2switch | ✅ |
| Remote post_deploy | o2switch | ✅ |
| Remote rollback | o2switch | ✅ |
| Notifications ntfy | - | ✅ |
| Registre JSON | - | ✅ |