Browse Source

Ajout conf pour serveur production

master
scayac 1 month ago
parent
commit
7284303692
  1. 27
      frontend/README_FRONTEND.md
  2. 1
      frontend/requirements.txt
  3. 17
      frontend/systemd/pysonnerie-frontend.service
  4. 4
      frontend/wsgi.py

27
frontend/README_FRONTEND.md

@ -30,6 +30,33 @@ python run.py
Application dispo sur `http://127.0.0.1:5000`. Application dispo sur `http://127.0.0.1:5000`.
## Production (Debian + systemd)
Le frontend peut tourner en production avec Gunicorn et un service systemd.
```bash
cd /opt/pySonnerie/frontend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
Copier le service fourni:
```bash
sudo cp systemd/pysonnerie-frontend.service /etc/systemd/system/
```
Adapter au besoin les variables dans le fichier de service (`FRONTEND_SECRET_KEY`, `FRONTEND_BIND`) puis activer:
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now pysonnerie-frontend.service
sudo systemctl status pysonnerie-frontend.service
```
Le frontend sera alors servi par Gunicorn sur l'adresse definie par `FRONTEND_BIND` (par defaut `0.0.0.0:5000`).
## Notes ## Notes
- Le frontend appelle le backend en HTTPS avec certificat autosigne (`verify=False`). - Le frontend appelle le backend en HTTPS avec certificat autosigne (`verify=False`).

1
frontend/requirements.txt

@ -1,2 +1,3 @@
Flask==3.0.3 Flask==3.0.3
requests==2.32.3 requests==2.32.3
gunicorn==23.0.0

17
frontend/systemd/pysonnerie-frontend.service

@ -0,0 +1,17 @@
[Unit]
Description=pySonnerie Frontend Web UI
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/pySonnerie/frontend
Environment=FRONTEND_SECRET_KEY=change-me
Environment=FRONTEND_BIND=0.0.0.0:5000
ExecStart=/opt/pySonnerie/frontend/.venv/bin/gunicorn --workers 2 --bind ${FRONTEND_BIND} wsgi:app
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target

4
frontend/wsgi.py

@ -0,0 +1,4 @@
from app import create_app
app = create_app()
Loading…
Cancel
Save