oneOS/DEPLOY.md
2026-04-02 06:53:43 +00:00

164 lines
3.4 KiB
Markdown

# one.OS — Deployment Guide
> **Stack:** Python 3 + Tornado · Single-File SPA (HTML) · Port 8080
> **Voraussetzung:** Ubuntu 22.04 LTS · Nginx · Python 3.10+
---
## 1. Erstmaliges Server-Setup
### 1.1 Abhängigkeiten installieren
```bash
sudo apt update && sudo apt install -y python3 python3-pip nginx git
```
### 1.2 Repository klonen
```bash
sudo git clone https://github.com/DEIN-USERNAME/one-os.git /opt/one-os
sudo chown -R www-data:www-data /opt/one-os
```
### 1.3 Python-Abhängigkeiten
```bash
sudo pip3 install -r /opt/one-os/one_os_webapp/requirements.txt --break-system-packages
```
---
## 2. Systemd Service einrichten
```bash
# Service-File kopieren
sudo cp /opt/one-os/one-os.service /etc/systemd/system/one-os.service
# Service aktivieren und starten
sudo systemctl daemon-reload
sudo systemctl enable one-os
sudo systemctl start one-os
# Status prüfen
sudo systemctl status one-os
```
Der Tornado-Server läuft jetzt auf `http://localhost:8080`.
---
## 3. Nginx als Reverse Proxy
Neue Konfigurationsdatei anlegen:
```bash
sudo nano /etc/nginx/sites-available/one-os
```
Inhalt:
```nginx
server {
listen 80;
server_name deine-domain.de; # ← anpassen
location / {
proxy_pass http://127.0.0.1:8080;
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;
proxy_read_timeout 60s;
}
}
```
```bash
# Aktivieren
sudo ln -s /etc/nginx/sites-available/one-os /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
```
### HTTPS mit Let's Encrypt (empfohlen)
```bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d deine-domain.de
```
---
## 4. Updates einspielen (ab hier: normaler Workflow)
```bash
sudo bash /opt/one-os/deploy.sh
```
Das Script macht automatisch:
1. `git pull` — neuesten Stand holen
2. Neueste `one.OS_local_v*.html``static/index.html` kopieren
3. Python-Abhängigkeiten aktualisieren
4. Service neu starten + Statuscheck
---
## 5. Logs & Monitoring
```bash
# Live-Logs
sudo journalctl -u one-os -f
# Letzte 50 Zeilen
sudo journalctl -u one-os -n 50 --no-pager
# Service-Status
sudo systemctl status one-os
```
---
## 6. Neue Version deployen (lokaler Workflow)
```bash
# 1. Lokal: neue Version erzeugen
# → one.OS_local_v1.7.21.html (Beispiel)
# 2. Zu git hinzufügen und pushen
git add one.OS_local_v1.7.21.html
git commit -m "feat: v1.7.21 - <kurze Beschreibung>"
git push origin main
# 3. Auf dem Server
sudo bash /opt/one-os/deploy.sh
```
---
## 7. Architektur-Übersicht
```
Internet
[Nginx :80/443] ← SSL-Terminierung, Reverse Proxy
[Tornado :8080] ← one.OS Backend + Static File Serving
├── GET / → redirect → /static/index.html
├── GET /static/* → one.OS Frontend (SPA)
└── /api/* → REST API (Liquid AI, Legal Fabric, ACE, ICP)
```
---
## 8. Troubleshooting
| Problem | Lösung |
|---------|--------|
| Service startet nicht | `journalctl -u one-os -n 50` prüfen |
| Port 8080 belegt | `sudo lsof -i :8080` → Prozess beenden |
| Nginx 502 Bad Gateway | Tornado läuft nicht: `systemctl restart one-os` |
| Python-Fehler | `pip3 install tornado --break-system-packages` |
| Keine Berechtigung | `sudo chown -R www-data:www-data /opt/one-os` |