feat(docker): dockerisation
This commit is contained in:
26
.env.docker
26
.env.docker
@@ -1,26 +0,0 @@
|
||||
# Configuration Docker pour Notytex v2
|
||||
# COPIEZ CE FICHIER EN .env ET MODIFIEZ LES VALEURS
|
||||
|
||||
# ⚠️ IMPORTANT: Générez une clé SECRET_KEY unique et sécurisée !
|
||||
# Commande: python -c "import secrets; print(secrets.token_hex(32))"
|
||||
SECRET_KEY=CHANGEZ-MOI-cle-secrete-unique-minimum-32-caracteres-obligatoire
|
||||
|
||||
# Base de données (stockée dans le volume ./data)
|
||||
DATABASE_URL=sqlite+aiosqlite:////data/school_management.db
|
||||
|
||||
# CORS - Ajustez selon vos domaines (ports Docker/Podman: 8080/8081)
|
||||
CORS_ORIGINS=["http://localhost:8081","http://localhost:8080","http://localhost:3000","https://votre-domaine.com"]
|
||||
|
||||
# Logging
|
||||
LOG_LEVEL=INFO
|
||||
|
||||
# Email (optionnel - pour l'envoi de bilans)
|
||||
# SMTP_HOST=smtp.gmail.com
|
||||
# SMTP_PORT=587
|
||||
# SMTP_USERNAME=votre-email@gmail.com
|
||||
# SMTP_PASSWORD=votre-mot-de-passe-app
|
||||
# EMAIL_FROM=votre-email@gmail.com
|
||||
# SMTP_USE_TLS=true
|
||||
|
||||
# Configuration production
|
||||
DEBUG=false
|
||||
@@ -1,32 +0,0 @@
|
||||
# Configuration du Registre Docker pour docker-compose.prod.yml
|
||||
# Copiez ce fichier en .env et ajustez les valeurs
|
||||
|
||||
# URL du registre Docker (sans https://)
|
||||
# Exemples:
|
||||
# - Docker Hub: docker.io
|
||||
# - GitHub: ghcr.io
|
||||
# - GitLab: registry.gitlab.com
|
||||
# - Gitea: git.example.com
|
||||
# - Harbor: harbor.example.com
|
||||
REGISTRY_URL=registry.example.com
|
||||
|
||||
# Namespace/Organisation dans le registre
|
||||
# Exemples:
|
||||
# - Docker Hub: votre-username
|
||||
# - GitHub: votre-username ou organisation
|
||||
# - GitLab: votre-username/projet
|
||||
# - Gitea: votre-username
|
||||
REGISTRY_NAMESPACE=myorganization
|
||||
|
||||
# Tag de l'image à utiliser
|
||||
# Options:
|
||||
# - latest (dernière version)
|
||||
# - v2.0.0 (version spécifique)
|
||||
# - rewrite (branche spécifique)
|
||||
# - main-abc123 (commit SHA)
|
||||
IMAGE_TAG=latest
|
||||
|
||||
# Note: Pour utiliser ces variables avec docker-compose.prod.yml:
|
||||
# 1. Copiez ce fichier: cp .env.registry.example .env
|
||||
# 2. Éditez .env avec vos valeurs
|
||||
# 3. Lancez: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
91
DOCKER.md
91
DOCKER.md
@@ -1,11 +1,100 @@
|
||||
# 🐳 Déploiement Docker - Notytex v2
|
||||
|
||||
Guide complet pour déployer Notytex avec Docker et Docker Compose.
|
||||
> **📍 Documentation Déplacée**
|
||||
> La documentation complète de déploiement Docker se trouve maintenant dans **[`docker/README.md`](docker/README.md)**
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Démarrage Rapide
|
||||
|
||||
**Nouvelle organisation** : Tous les fichiers Docker sont maintenant dans le dossier `docker/`
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
cp .env.example .env
|
||||
# Éditez .env et changez SECRET_KEY
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
**Accès :**
|
||||
- Frontend : http://localhost:8081
|
||||
- API Backend : http://localhost:8080
|
||||
|
||||
**Documentation complète :** Voir [`docker/README.md`](docker/README.md)
|
||||
|
||||
---
|
||||
|
||||
## 📂 Nouvelle Structure
|
||||
|
||||
```
|
||||
notytex/
|
||||
├── docker/ # 📁 Dossier dédié Docker
|
||||
│ ├── compose.yaml # Production (défaut)
|
||||
│ ├── compose.override.yaml # Développement (auto-merge)
|
||||
│ ├── .env.example # Template variables
|
||||
│ └── README.md # Documentation complète
|
||||
├── backend/
|
||||
│ └── Dockerfile
|
||||
├── frontend/
|
||||
│ └── Dockerfile
|
||||
└── data/ # Volume persistant
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Modes d'Utilisation
|
||||
|
||||
### Mode Développement
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
docker compose up # Build local + hot-reload
|
||||
```
|
||||
|
||||
### Mode Production
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
docker compose -f compose.yaml up -d # Images du registre
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📖 Documentation Complète
|
||||
|
||||
Pour plus d'informations sur :
|
||||
- Configuration avancée
|
||||
- Variables d'environnement
|
||||
- Utilisation avec Podman
|
||||
- Déploiement production
|
||||
- Dépannage
|
||||
- CI/CD
|
||||
|
||||
👉 **Consultez [`docker/README.md`](docker/README.md)**
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Migration depuis l'Ancienne Organisation
|
||||
|
||||
Si vous utilisez les anciens fichiers `docker-compose.yml` et `docker-compose.prod.yml` :
|
||||
|
||||
```bash
|
||||
# Arrêter les anciens conteneurs
|
||||
docker-compose down
|
||||
|
||||
# Utiliser la nouvelle organisation
|
||||
cd docker
|
||||
cp .env.example .env
|
||||
# Éditez .env
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Les anciens fichiers seront supprimés dans une version future.
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Démarrage Rapide (Ancien Format - Déprécié)
|
||||
|
||||
### Prérequis
|
||||
|
||||
- **Docker** : 24.0+ (ou Docker Desktop 4.20+)
|
||||
|
||||
@@ -43,11 +43,12 @@ npm run dev
|
||||
|
||||
```bash
|
||||
# Configuration
|
||||
cp .env.docker .env
|
||||
cd docker
|
||||
cp .env.example .env
|
||||
# Éditez .env et changez SECRET_KEY
|
||||
|
||||
# Démarrage (Docker ou Podman)
|
||||
docker-compose up -d
|
||||
docker compose up -d
|
||||
# ou
|
||||
podman-compose up -d
|
||||
```
|
||||
@@ -59,7 +60,7 @@ podman-compose up -d
|
||||
|
||||
> 💡 **Ports sans privilèges** : Les ports 8080/8081 permettent l'utilisation avec Podman sans root
|
||||
|
||||
📖 **Documentation complète** : [`DOCKER.md`](DOCKER.md)
|
||||
📖 **Documentation complète** : [`docker/README.md`](docker/README.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# Docker Compose pour Production avec images du registre
|
||||
# Usage: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
#
|
||||
# Variables d'environnement requises:
|
||||
# REGISTRY_URL - URL de votre registre Docker (ex: registry.example.com, ghcr.io, docker.io)
|
||||
# REGISTRY_NAMESPACE - Namespace/organisation (ex: notytex, username)
|
||||
# IMAGE_TAG - Tag de l'image (défaut: latest)
|
||||
#
|
||||
# Exemple:
|
||||
# export REGISTRY_URL=registry.example.com
|
||||
# export REGISTRY_NAMESPACE=myorg
|
||||
# export IMAGE_TAG=latest
|
||||
# docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/notytex-backend:${IMAGE_TAG:-latest}
|
||||
build: null # Désactive le build local
|
||||
|
||||
frontend:
|
||||
image: ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/notytex-frontend:${IMAGE_TAG:-latest}
|
||||
build: null # Désactive le build local
|
||||
89
docker/.env.example
Normal file
89
docker/.env.example
Normal file
@@ -0,0 +1,89 @@
|
||||
# Configuration Docker Compose pour Notytex v2
|
||||
# COPIEZ CE FICHIER EN .env ET MODIFIEZ LES VALEURS
|
||||
|
||||
# =============================================================================
|
||||
# SÉCURITÉ - OBLIGATOIRE
|
||||
# =============================================================================
|
||||
|
||||
# ⚠️ IMPORTANT: Générez une clé SECRET_KEY unique et sécurisée !
|
||||
# Commande: python -c "import secrets; print(secrets.token_hex(32))"
|
||||
SECRET_KEY=CHANGEZ-MOI-cle-secrete-unique-minimum-32-caracteres-obligatoire
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURATION PRODUCTION (Images du registre)
|
||||
# =============================================================================
|
||||
|
||||
# URL du registre Docker (exemples ci-dessous)
|
||||
# - Docker Hub: docker.io
|
||||
# - GitHub Container Registry: ghcr.io
|
||||
# - GitLab Registry: registry.gitlab.com
|
||||
# - Gitea Registry: git.example.com
|
||||
REGISTRY_URL=git.opytex.org
|
||||
|
||||
# Namespace/organisation sur le registre
|
||||
# Exemples: votre-username, votre-organisation, notytex
|
||||
REGISTRY_NAMESPACE=notytex
|
||||
|
||||
# Tag de l'image (version)
|
||||
# Exemples: latest, v2.0.0, main, develop
|
||||
IMAGE_TAG=latest
|
||||
|
||||
# =============================================================================
|
||||
# PORTS EXPOSÉS
|
||||
# =============================================================================
|
||||
|
||||
# Port du backend API (défaut: 8080)
|
||||
BACKEND_PORT=8080
|
||||
|
||||
# Port du frontend web (défaut: 8081)
|
||||
FRONTEND_PORT=8081
|
||||
|
||||
# =============================================================================
|
||||
# BASE DE DONNÉES
|
||||
# =============================================================================
|
||||
|
||||
# L'URL de la base de données est fixée en SQLite dans compose.yaml
|
||||
# Le fichier est stocké dans ../data/school_management.db (volume persistant)
|
||||
# Pour changer de DB (PostgreSQL, MySQL), modifiez compose.yaml
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURATION APPLICATIVE
|
||||
# =============================================================================
|
||||
|
||||
# Niveau de logs (DEBUG, INFO, WARNING, ERROR)
|
||||
LOG_LEVEL=INFO
|
||||
|
||||
# CORS - Domaines autorisés (format JSON array)
|
||||
# En production, ajustez avec vos vrais domaines
|
||||
CORS_ORIGINS=["http://localhost:8081","http://localhost:8080","https://votre-domaine.com"]
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURATION EMAIL (Optionnel - pour envoi de bilans)
|
||||
# =============================================================================
|
||||
|
||||
# Serveur SMTP
|
||||
# SMTP_HOST=smtp.gmail.com
|
||||
# SMTP_PORT=587
|
||||
# SMTP_USERNAME=votre-email@gmail.com
|
||||
# SMTP_PASSWORD=votre-mot-de-passe-app
|
||||
# EMAIL_FROM=votre-email@gmail.com
|
||||
# SMTP_USE_TLS=true
|
||||
|
||||
# =============================================================================
|
||||
# NOTES D'UTILISATION
|
||||
# =============================================================================
|
||||
|
||||
# MODE DÉVELOPPEMENT (build local avec hot-reload):
|
||||
# cd docker
|
||||
# docker compose up
|
||||
# (utilise automatiquement compose.yaml + compose.override.yaml)
|
||||
|
||||
# MODE PRODUCTION (images du registre):
|
||||
# cd docker
|
||||
# docker compose -f compose.yaml up -d
|
||||
# (utilise uniquement compose.yaml, sans override)
|
||||
|
||||
# ACCÈS:
|
||||
# - Frontend: http://localhost:8081
|
||||
# - API Backend: http://localhost:8080
|
||||
# - API Docs: http://localhost:8080/api/v2/docs
|
||||
6
docker/.gitignore
vendored
Normal file
6
docker/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# Fichier de configuration local (contient des secrets)
|
||||
.env
|
||||
|
||||
# Fichiers temporaires Docker
|
||||
*.log
|
||||
.dockerignore
|
||||
452
docker/README.md
Normal file
452
docker/README.md
Normal file
@@ -0,0 +1,452 @@
|
||||
# 🐳 Déploiement Docker - Notytex v2
|
||||
|
||||
Guide complet pour déployer Notytex avec Docker et Docker Compose.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Démarrage Rapide
|
||||
|
||||
### Prérequis
|
||||
|
||||
- **Docker** : 24.0+ (ou Docker Desktop 4.20+)
|
||||
- **Docker Compose** : 2.20+
|
||||
- **Alternative Podman** : Podman 4.0+ avec podman-compose
|
||||
|
||||
### Installation en 3 commandes
|
||||
|
||||
```bash
|
||||
# 1. Configurer l'environnement
|
||||
cd docker
|
||||
cp .env.example .env
|
||||
# Éditez .env et changez SECRET_KEY !
|
||||
|
||||
# 2. Créer le répertoire de données (si nécessaire)
|
||||
mkdir -p ../data
|
||||
|
||||
# 3. Démarrer les services
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
**Accès :**
|
||||
- Frontend : http://localhost:8081
|
||||
- API Backend : http://localhost:8080
|
||||
- Documentation API : http://localhost:8080/api/v2/docs
|
||||
|
||||
---
|
||||
|
||||
## 📂 Organisation des Fichiers
|
||||
|
||||
```
|
||||
docker/
|
||||
├── compose.yaml # Configuration PRODUCTION (défaut)
|
||||
├── compose.override.yaml # Override DÉVELOPPEMENT (auto-merge)
|
||||
├── .env.example # Template de variables d'environnement
|
||||
└── README.md # Ce fichier
|
||||
|
||||
../backend/
|
||||
├── Dockerfile # Image backend FastAPI
|
||||
└── ...
|
||||
|
||||
../frontend/
|
||||
├── Dockerfile # Image frontend Vue.js + Nginx
|
||||
└── ...
|
||||
|
||||
../data/ # Volume persistant (base de données SQLite)
|
||||
└── school_management.db
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Variables d'Environnement
|
||||
|
||||
Copiez `.env.example` vers `.env` et personnalisez :
|
||||
|
||||
```bash
|
||||
# Clé secrète (OBLIGATOIRE - générez-en une nouvelle !)
|
||||
SECRET_KEY=votre-cle-secrete-unique-min-32-chars
|
||||
|
||||
# Configuration du registre Docker (pour production avec images pré-buildées)
|
||||
REGISTRY_URL=docker.io
|
||||
REGISTRY_NAMESPACE=notytex
|
||||
IMAGE_TAG=latest
|
||||
|
||||
# Ports exposés
|
||||
BACKEND_PORT=8080
|
||||
FRONTEND_PORT=8081
|
||||
|
||||
# CORS (ajoutez vos domaines en production)
|
||||
CORS_ORIGINS=["http://localhost:8081","https://votre-domaine.com"]
|
||||
```
|
||||
|
||||
### Générer une SECRET_KEY
|
||||
|
||||
```bash
|
||||
python -c "import secrets; print(secrets.token_hex(32))"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Modes d'Utilisation
|
||||
|
||||
### Mode Développement (Build Local + Hot-Reload)
|
||||
|
||||
**Utilise automatiquement** : `compose.yaml` + `compose.override.yaml`
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
|
||||
# Démarrer avec build local et volumes montés
|
||||
docker compose up
|
||||
|
||||
# Rebuild après modification du code
|
||||
docker compose up --build
|
||||
|
||||
# Voir les logs en temps réel
|
||||
docker compose logs -f
|
||||
|
||||
# Arrêter
|
||||
docker compose down
|
||||
```
|
||||
|
||||
**Caractéristiques du mode dev** :
|
||||
- ✅ Build local des images depuis `../backend` et `../frontend`
|
||||
- ✅ Volumes montés pour hot-reload backend
|
||||
- ✅ Logs DEBUG activés
|
||||
- ✅ Health checks moins stricts
|
||||
|
||||
### Mode Production (Images du Registre)
|
||||
|
||||
**Utilise uniquement** : `compose.yaml` (sans override)
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
|
||||
# Démarrer avec images pré-buildées du registre
|
||||
docker compose -f compose.yaml up -d
|
||||
|
||||
# Voir le statut
|
||||
docker compose -f compose.yaml ps
|
||||
|
||||
# Voir les logs
|
||||
docker compose -f compose.yaml logs -f
|
||||
|
||||
# Arrêter
|
||||
docker compose -f compose.yaml down
|
||||
```
|
||||
|
||||
**Caractéristiques du mode production** :
|
||||
- ✅ Images pré-buildées depuis le registre Docker
|
||||
- ✅ Pas de volumes de code (images complètes)
|
||||
- ✅ Logs INFO/WARNING
|
||||
- ✅ Health checks stricts
|
||||
- ✅ Restart automatique (`unless-stopped`)
|
||||
|
||||
---
|
||||
|
||||
## 🐋 Utilisation avec Podman
|
||||
|
||||
### Pourquoi Podman ?
|
||||
|
||||
- **Sans privilèges root** : Exécution en mode utilisateur (rootless)
|
||||
- **Compatible Docker** : Même syntaxe que docker-compose
|
||||
- **Plus sécurisé** : Pas de daemon en arrière-plan
|
||||
|
||||
### Installation Podman
|
||||
|
||||
```bash
|
||||
# Debian/Ubuntu
|
||||
sudo apt install podman podman-compose
|
||||
|
||||
# Fedora/RHEL
|
||||
sudo dnf install podman podman-compose
|
||||
|
||||
# Arch Linux
|
||||
sudo pacman -S podman podman-compose
|
||||
```
|
||||
|
||||
### Commandes Podman
|
||||
|
||||
```bash
|
||||
# Remplacer 'docker compose' par 'podman-compose'
|
||||
cd docker
|
||||
podman-compose up -d
|
||||
podman-compose logs -f
|
||||
podman-compose down
|
||||
|
||||
# Ou utiliser l'alias podman (compatible Docker CLI)
|
||||
alias docker=podman
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Gestion de la Base de Données
|
||||
|
||||
### Backup
|
||||
|
||||
```bash
|
||||
# Backup manuel
|
||||
docker compose exec backend sh -c "cp /data/school_management.db /data/backup_$(date +%Y%m%d_%H%M%S).db"
|
||||
|
||||
# Ou depuis l'hôte
|
||||
cp ../data/school_management.db ../data/backup_$(date +%Y%m%d_%H%M%S).db
|
||||
```
|
||||
|
||||
### Restauration
|
||||
|
||||
```bash
|
||||
# Restaurer depuis un backup
|
||||
docker compose stop backend
|
||||
cp ../data/backup_YYYYMMDD_HHMMSS.db ../data/school_management.db
|
||||
docker compose start backend
|
||||
```
|
||||
|
||||
### Migration depuis v1
|
||||
|
||||
```bash
|
||||
# Si vous avez une base v1 Flask
|
||||
cp ../instance/school_management.db ../data/school_management.db
|
||||
docker compose restart backend
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Healthcheck et Monitoring
|
||||
|
||||
Les services incluent des healthchecks automatiques :
|
||||
|
||||
```bash
|
||||
# Vérifier la santé du backend
|
||||
curl http://localhost:8080/api/v2/health
|
||||
|
||||
# Vérifier la santé du frontend
|
||||
curl http://localhost:8081/
|
||||
|
||||
# Voir le statut Docker
|
||||
docker compose ps
|
||||
```
|
||||
|
||||
**Réponse attendue du backend :**
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"database": "connected",
|
||||
"tables": 12,
|
||||
"classes": 5,
|
||||
"students": 155
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Dépannage
|
||||
|
||||
### Le backend ne démarre pas
|
||||
|
||||
```bash
|
||||
# Voir les logs
|
||||
docker compose logs backend
|
||||
|
||||
# Vérifier la configuration
|
||||
docker compose exec backend env | grep DATABASE_URL
|
||||
|
||||
# Recréer le conteneur
|
||||
docker compose up -d --force-recreate backend
|
||||
```
|
||||
|
||||
### Le frontend ne charge pas
|
||||
|
||||
```bash
|
||||
# Vérifier Nginx
|
||||
docker compose logs frontend
|
||||
|
||||
# Tester la connectivité au backend
|
||||
docker compose exec frontend curl http://backend:8000/api/v2/health
|
||||
|
||||
# Rebuild le frontend
|
||||
docker compose build frontend
|
||||
docker compose up -d frontend
|
||||
```
|
||||
|
||||
### Problème de permissions (base de données)
|
||||
|
||||
```bash
|
||||
# Ajuster les permissions
|
||||
chmod 666 ../data/school_management.db
|
||||
chmod 755 ../data/
|
||||
```
|
||||
|
||||
### Les changements de code ne sont pas pris en compte
|
||||
|
||||
```bash
|
||||
# Rebuild complet
|
||||
docker compose down
|
||||
docker compose build --no-cache
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Déploiement Production
|
||||
|
||||
### Configuration Nginx (hôte)
|
||||
|
||||
Si vous utilisez Nginx sur l'hôte pour le reverse proxy :
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name notytex.example.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8081;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### HTTPS avec Let's Encrypt
|
||||
|
||||
```bash
|
||||
# Installer certbot
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtenir un certificat
|
||||
sudo certbot --nginx -d notytex.example.com
|
||||
```
|
||||
|
||||
### Systemd Service
|
||||
|
||||
Créez `/etc/systemd/system/notytex.service` :
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Notytex Docker Compose
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/path/to/notytex/docker
|
||||
ExecStart=/usr/bin/docker compose -f compose.yaml up -d
|
||||
ExecStop=/usr/bin/docker compose -f compose.yaml down
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Activer :
|
||||
```bash
|
||||
sudo systemctl enable notytex
|
||||
sudo systemctl start notytex
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
### Logs centralisés
|
||||
|
||||
```bash
|
||||
# Tous les logs en temps réel
|
||||
docker compose logs -f
|
||||
|
||||
# Logs des dernières 24h
|
||||
docker compose logs --since 24h
|
||||
|
||||
# Recherche dans les logs
|
||||
docker compose logs | grep ERROR
|
||||
```
|
||||
|
||||
### Métriques Docker
|
||||
|
||||
```bash
|
||||
# Utilisation ressources
|
||||
docker stats
|
||||
|
||||
# Espace disque
|
||||
docker system df
|
||||
|
||||
# Nettoyage
|
||||
docker system prune -a
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Sécurité - Checklist Production
|
||||
|
||||
- [ ] Changer `SECRET_KEY` (unique et aléatoire)
|
||||
- [ ] Configurer CORS avec vos domaines réels
|
||||
- [ ] Utiliser HTTPS en production
|
||||
- [ ] Limiter les ports exposés (firewall)
|
||||
- [ ] Mettre en place des backups automatiques
|
||||
- [ ] Configurer des alertes monitoring
|
||||
- [ ] Restreindre les permissions fichiers
|
||||
- [ ] Mettre à jour régulièrement les images Docker
|
||||
|
||||
---
|
||||
|
||||
## 🔄 CI/CD - Images du Registre
|
||||
|
||||
### Configuration CI/CD
|
||||
|
||||
Le projet inclut `.gitea/workflows/docker-publish.yml` pour la construction automatique des images Docker.
|
||||
|
||||
**Déclencheurs** :
|
||||
- Push sur `main` ou `rewrite`
|
||||
- Tags `v*` (releases)
|
||||
- Déclenchement manuel
|
||||
|
||||
**Variables requises (Secrets)** :
|
||||
- `REGISTRY_URL` - URL de votre registre Docker
|
||||
- `REGISTRY_NAMESPACE` - Namespace/organisation
|
||||
- `REGISTRY_USERNAME` - Nom d'utilisateur pour le registre
|
||||
- `REGISTRY_PASSWORD` - Mot de passe ou token pour le registre
|
||||
|
||||
### Utiliser les images du registre
|
||||
|
||||
```bash
|
||||
# 1. Se connecter au registre (si privé)
|
||||
docker login <REGISTRY_URL>
|
||||
|
||||
# 2. Pull des images
|
||||
docker pull <REGISTRY_URL>/<NAMESPACE>/notytex-backend:latest
|
||||
docker pull <REGISTRY_URL>/<NAMESPACE>/notytex-frontend:latest
|
||||
|
||||
# 3. Configurer .env
|
||||
REGISTRY_URL=registry.example.com
|
||||
REGISTRY_NAMESPACE=myorg
|
||||
IMAGE_TAG=latest
|
||||
|
||||
# 4. Démarrer
|
||||
docker compose -f compose.yaml up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Ressources Recommandées
|
||||
|
||||
- **Backend** : 512MB RAM, 0.5 CPU
|
||||
- **Frontend** : 256MB RAM, 0.25 CPU
|
||||
- **Total** : ~1GB RAM, 1 CPU pour 50 utilisateurs
|
||||
|
||||
---
|
||||
|
||||
## 📞 Support
|
||||
|
||||
En cas de problème :
|
||||
|
||||
1. Vérifiez les logs : `docker compose logs`
|
||||
2. Testez les healthchecks
|
||||
3. Consultez la documentation principale : `../README.md`
|
||||
4. Vérifiez les issues GitHub
|
||||
|
||||
---
|
||||
|
||||
**Développé avec ❤️ pour simplifier le déploiement de Notytex**
|
||||
32
docker/docker-compose.dev.yaml
Normal file
32
docker/docker-compose.dev.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
# Docker Compose - Override pour Développement
|
||||
# Ce fichier est automatiquement fusionné avec compose.yaml quand vous lancez: docker compose up
|
||||
# Il active le hot-reload et monte les volumes de code source
|
||||
|
||||
services:
|
||||
# Backend - Mode développement avec hot-reload
|
||||
backend:
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: Dockerfile
|
||||
image: notytex-backend:dev
|
||||
environment:
|
||||
- LOG_LEVEL=DEBUG
|
||||
- DEBUG=true
|
||||
volumes:
|
||||
# Monte le code source pour le hot-reload
|
||||
- ../backend:/app
|
||||
# Volume data persistant
|
||||
- ../data:/data
|
||||
# Désactive les health checks stricts en dev
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
retries: 5
|
||||
|
||||
# Frontend - Mode développement avec hot-reload
|
||||
frontend:
|
||||
build:
|
||||
context: ../frontend
|
||||
dockerfile: Dockerfile
|
||||
image: notytex-frontend:dev
|
||||
# Pas besoin de volumes montés car Nginx sert les fichiers buildés
|
||||
# Pour le hot-reload frontend, utilisez plutôt: cd frontend && npm run dev
|
||||
@@ -1,25 +1,22 @@
|
||||
version: '3.8'
|
||||
# Docker Compose - Configuration Production
|
||||
# Usage: docker compose up -d
|
||||
# Documentation: ./README.md
|
||||
|
||||
services:
|
||||
# Backend FastAPI
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
image: ${REGISTRY_URL:-git.opytex.org}/${REGISTRY_NAMESPACE:-notytex}/notytex-backend:${IMAGE_TAG:-latest}
|
||||
container_name: notytex-backend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8000"
|
||||
- "${BACKEND_PORT:-8080}:8000"
|
||||
environment:
|
||||
- DATABASE_URL=sqlite+aiosqlite:////data/school_management.db
|
||||
- SECRET_KEY=${SECRET_KEY:-change-me-in-production-min-32-chars}
|
||||
- CORS_ORIGINS=["http://localhost:8081","http://localhost:8080","http://localhost:3000"]
|
||||
- LOG_LEVEL=INFO
|
||||
- SECRET_KEY=${SECRET_KEY:?SECRET_KEY est obligatoire - voir .env.example}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS:-["http://localhost:8081","http://localhost:8080"]}
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- ./backend:/app
|
||||
networks:
|
||||
- notytex-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v2/health"]
|
||||
interval: 30s
|
||||
@@ -29,27 +26,16 @@ services:
|
||||
|
||||
# Frontend Vue.js + Nginx
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
image: ${REGISTRY_URL:-git.opytex.org}/${REGISTRY_NAMESPACE:-notytex}/notytex-frontend:${IMAGE_TAG:-latest}
|
||||
container_name: notytex-frontend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8081:80"
|
||||
- "${FRONTEND_PORT:-8081}:80"
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- notytex-network
|
||||
backend:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
networks:
|
||||
notytex-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
Reference in New Issue
Block a user