Update README with deployment and env docs
This commit is contained in:
120
README.md
120
README.md
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
## Überblick
|
## Überblick
|
||||||
Dieses Repository enthält:
|
Dieses Repository enthält:
|
||||||
- **WaWi‑App** (Flask + SQLite) für Artikelverwaltung, Ausbuchen und Verkäufe.
|
- **WaWi‑App** (Flask + SQLite) für Artikelverwaltung, Ausbuchen, Verkäufe und Bestellungen.
|
||||||
- **Live‑Bestand Ansicht** (`index.html`) die den Bestand aus der WaWi‑API lädt.
|
- **Live‑Shop‑Ansicht** (`index.html`) lädt Daten aus der WaWi‑App.
|
||||||
- **Import‑Script** für Daten aus der ursprünglichen `hellas_bestand.html`.
|
- **Import‑Script** für Daten aus der ursprünglichen `hellas_bestand.html`.
|
||||||
|
|
||||||
## Struktur
|
## Struktur
|
||||||
@@ -12,14 +12,14 @@ Dieses Repository enthält:
|
|||||||
- `wawi/static/` – Styles + Logo
|
- `wawi/static/` – Styles + Logo
|
||||||
- `wawi/hellas.db` – SQLite‑Datenbank (wird automatisch erstellt)
|
- `wawi/hellas.db` – SQLite‑Datenbank (wird automatisch erstellt)
|
||||||
- `wawi/import_from_html.py` – Import aus `hellas_bestand.html`
|
- `wawi/import_from_html.py` – Import aus `hellas_bestand.html`
|
||||||
- `index.html` – Live‑Bestand Ansicht (ruft `/wawi/proxy/bestand`)
|
- `index.html` – Live‑Shop‑Ansicht (ruft `/wawi/proxy/bestand`)
|
||||||
|
|
||||||
## WaWi lokal starten
|
## WaWi lokal starten
|
||||||
```bash
|
```bash
|
||||||
cd wawi
|
cd wawi
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
pip install flask
|
pip install flask gunicorn
|
||||||
python app.py
|
python app.py
|
||||||
```
|
```
|
||||||
Standardzugriff: Login über Benutzerverwaltung (siehe unten).
|
Standardzugriff: Login über Benutzerverwaltung (siehe unten).
|
||||||
@@ -38,19 +38,115 @@ cd wawi
|
|||||||
python import_from_html.py /pfad/zu/hellas_bestand.html --truncate
|
python import_from_html.py /pfad/zu/hellas_bestand.html --truncate
|
||||||
```
|
```
|
||||||
|
|
||||||
## Live‑Bestand Ansicht (index.html)
|
## Live‑Shop‑Ansicht (index.html)
|
||||||
`index.html` lädt den Bestand aus der WaWi‑App:
|
`index.html` lädt den Bestand aus der WaWi‑App:
|
||||||
- API‑Proxy: `/wawi/proxy/bestand`
|
- API‑Proxy: `/wawi/proxy/bestand`
|
||||||
|
|
||||||
Wenn du diese Datei auf einem Webserver auslieferst, stelle sicher, dass die WaWi‑App unter `/wawi` erreichbar ist.
|
Wenn du diese Datei auf einem Webserver auslieferst, stelle sicher, dass die WaWi‑App unter `/wawi` erreichbar ist.
|
||||||
|
|
||||||
## Deployment (Kurz)
|
## Umgebungsvariablen (ENV)
|
||||||
|
**Pflicht/Empfohlen für Produktion**
|
||||||
|
- `SECRET_KEY` – Session‑Secret
|
||||||
|
- `APP_USER` / `APP_PASSWORD` – initialer Admin‑User
|
||||||
|
- `URL_PREFIX` – z. B. `/wawi` (wenn hinter Sub‑Pfad)
|
||||||
|
|
||||||
|
**E‑Mail (Bestellungen)**
|
||||||
|
- `SMTP_HOST` – SMTP‑Server
|
||||||
|
- `SMTP_PORT` – z. B. `587`
|
||||||
|
- `SMTP_USER` / `SMTP_PASS` – SMTP Login
|
||||||
|
- `SMTP_FROM` – Absender (z. B. `bestand@hellas.welker.me`)
|
||||||
|
- `ORDER_TO` – Empfänger, mehrere per Komma
|
||||||
|
|
||||||
|
**Optional**
|
||||||
|
- `APP_API_KEY` – API‑Key für direkten Zugriff auf `/wawi/api/bestand`
|
||||||
|
|
||||||
|
## Deployment (systemd + Gunicorn)
|
||||||
1) App nach `/var/www/hellas/wawi` kopieren
|
1) App nach `/var/www/hellas/wawi` kopieren
|
||||||
2) Gunicorn + systemd starten
|
2) venv erstellen:
|
||||||
3) Nginx Reverse‑Proxy auf `/wawi`
|
```bash
|
||||||
|
cd /var/www/hellas/wawi
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install flask gunicorn
|
||||||
|
```
|
||||||
|
3) Service‑Datei anlegen: `/etc/systemd/system/hellas.service`
|
||||||
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Hellas WaWi
|
||||||
|
After=network.target
|
||||||
|
|
||||||
Für Produktion setze:
|
[Service]
|
||||||
- `SECRET_KEY` (Session‑Cookie)
|
User=www-data
|
||||||
- `APP_USER`, `APP_PASSWORD` (Admin)
|
Group=www-data
|
||||||
- optional `APP_API_KEY` (für direkten API‑Zugriff)
|
WorkingDirectory=/var/www/hellas/wawi
|
||||||
|
Environment="PATH=/var/www/hellas/wawi/.venv/bin"
|
||||||
|
Environment="URL_PREFIX=/wawi"
|
||||||
|
Environment="SECRET_KEY=DEIN_SECRET"
|
||||||
|
Environment="APP_USER=admin"
|
||||||
|
Environment="APP_PASSWORD=starkesPasswort"
|
||||||
|
Environment="SMTP_HOST=smtp.example.com"
|
||||||
|
Environment="SMTP_PORT=587"
|
||||||
|
Environment="SMTP_USER=dein_user"
|
||||||
|
Environment="SMTP_PASS=dein_pass"
|
||||||
|
Environment="SMTP_FROM=bestand@hellas.welker.me"
|
||||||
|
Environment="ORDER_TO=bjoern@welker.me, zweite@domain.de"
|
||||||
|
Environment="APP_API_KEY=api_f4b8e1c97a2d4e5b8c6a9d3e2f7b1a0c"
|
||||||
|
ExecStart=/var/www/hellas/wawi/.venv/bin/gunicorn -w 3 -b 127.0.0.1:8000 app:app
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
4) Aktivieren:
|
||||||
|
```bash
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now hellas
|
||||||
|
```
|
||||||
|
|
||||||
|
## Nginx (Reverse‑Proxy + Shop‑Seite)
|
||||||
|
Beispiel `/etc/nginx/sites-available/hellas`:
|
||||||
|
```
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name hellas.welker.me;
|
||||||
|
|
||||||
|
location = / {
|
||||||
|
root /var/www/hellas;
|
||||||
|
try_files /index.html =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /wawi/ {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Aktivieren:
|
||||||
|
```bash
|
||||||
|
sudo ln -s /etc/nginx/sites-available/hellas /etc/nginx/sites-enabled/hellas
|
||||||
|
sudo nginx -t
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
## SSL (Let’s Encrypt)
|
||||||
|
```bash
|
||||||
|
sudo apt install -y certbot python3-certbot-nginx
|
||||||
|
sudo certbot --nginx -d hellas.welker.me
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dateirechte (SQLite + Uploads)
|
||||||
|
```bash
|
||||||
|
sudo chown -R www-data:www-data /var/www/hellas/wawi
|
||||||
|
sudo chmod 750 /var/www/hellas/wawi
|
||||||
|
sudo chmod 640 /var/www/hellas/wawi/hellas.db
|
||||||
|
sudo mkdir -p /var/www/hellas/wawi/static/uploads
|
||||||
|
sudo chown -R www-data:www-data /var/www/hellas/wawi/static/uploads
|
||||||
|
```
|
||||||
|
|
||||||
|
## Backup (Beispiel)
|
||||||
|
```bash
|
||||||
|
sudo /root/fix_wawi_permissions.sh
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user