# Central Application de supervision du SI Malio. Permet de piloter le mode maintenance de toutes les applications sans se connecter a chaque projet. ## Installation ```bash make start make install make fixtures ``` ## Acces - Frontend : http://localhost:8084 - API : http://localhost:8084/api - Dev Nuxt (hot reload) : http://localhost:3003 - Login : `admin` / `admin` ## Applications gerees | Application | Slug | Port prod | Fichier maintenance | |-------------|------|-----------|---------------------| | SIRH | `sirh` | 8080 | `/var/www/sirh/maintenance.on` | | Lesstime | `lesstime` | 8081 | `/var/www/lesstime/maintenance.on` | | Inventory | `inventory` | 8082 | `/var/www/inventory/maintenance.on` | La configuration est dans `config/applications.yaml`. ## Comment fonctionne la maintenance ### Architecture ``` Central (container Docker, port 8084) | | Volumes Docker : | /var/www/sirh (hote) --> /var/www/maintenance/sirh (container) | /var/www/lesstime (hote) --> /var/www/maintenance/lesstime (container) | /var/www/inventory (hote) --> /var/www/maintenance/inventory (container) | | Quand l'admin clique "Activer maintenance" sur Lesstime : | v API : POST /api/applications/lesstime/maintenance { "maintenance": true } | v MaintenanceToggleProcessor --> touch /var/www/maintenance/lesstime/maintenance.on (dans le container) --> via le volume Docker, cree /var/www/lesstime/maintenance.on sur l'hote | v Nginx de l'hote (reverse proxy de Lesstime) : if (-f /var/www/lesstime/maintenance.on) --> return 503 --> sert /var/www/lesstime/public/maintenance.html ``` ### Cote Central (ce projet) 1. `config/applications.yaml` definit les apps et leur `maintenance_path` (variable d'env) 2. Les variables d'env (`SIRH_MAINTENANCE_PATH`, etc.) pointent vers `/var/www/maintenance/{slug}/maintenance.on` 3. Le `docker-compose.yml` prod monte les dossiers de deploy des apps vers `/var/www/maintenance/` 4. `MaintenanceToggleProcessor` cree ou supprime le fichier `maintenance.on` 5. `ManagedApplicationProvider` lit `file_exists()` pour afficher l'etat actuel ### Cote application cible (SIRH, Lesstime, Inventory) Chaque application doit avoir : 1. **Un `maintenance.html`** dans `/var/www/{app}/public/` sur le serveur (extrait automatiquement par `deploy.sh`) 2. **Un nginx reverse proxy sur l'hote** qui verifie l'existence du fichier `maintenance.on` : ```nginx server { server_name app.malio-dev.fr; root /var/www/{app}/public; if (-f /var/www/{app}/maintenance.on) { return 503; } error_page 503 @maintenance; location @maintenance { rewrite ^(.*)$ /maintenance.html break; } location = /maintenance.html { internal; } location / { proxy_pass http://127.0.0.1:{port}; # headers... } } ``` ### Ajouter une nouvelle application 1. Ajouter l'entree dans `config/applications.yaml` 2. Ajouter la variable d'env `{APP}_MAINTENANCE_PATH` dans `.env` et `.env` prod 3. Ajouter le volume dans `docker-compose.yml` prod : `/var/www/{app}:/var/www/maintenance/{app}` 4. Configurer le nginx reverse proxy de l'hote pour la nouvelle app (voir ci-dessus) 5. S'assurer que `maintenance.html` existe dans `/var/www/{app}/public/` ## Stack - **Backend** : PHP 8.4, Symfony 8.0, API Platform 4 - **Frontend** : Nuxt 4 (SPA), Vue 3, Tailwind CSS - **Auth** : JWT HTTP-only cookie - **Docker** : PHP-FPM + Nginx + Supervisor ## Deploiement Voir `doc/deployment-docker.md` pour le guide complet. ```bash cd /var/www/central ./deploy.sh # latest ./deploy.sh v0.1.5 # version specifique ```