257cafcb210683649f0fb49b623dc8b0c66c73e9
- Added tenant verification checklist in TENANT_VERIFICATION.md for system validation. - Created tenant_config.py to manage tenant-specific configurations with global defaults and per-tenant overrides. - Introduced tenant_guards.py for route protection based on module availability. - Developed tenant_resolver.py for identifying active tenants from requests using subdomains and headers. - Added tenant_templates.py for Jinja2 template helpers to check module visibility. - Created error_403.html for custom 403 error handling. - Defined tenants.json for tenant configurations and module management. - Implemented unit tests in test_tenant_system.py to ensure functionality of tenant system components. Co-authored-by: Copilot <copilot@github.com>
Key Service Server
Dieses Repository ist auf einen schlanken, Docker-first Betrieb ausgerichtet.
Voraussetzungen
- Docker Engine + Docker Compose Plugin
- Nginx
- OpenSSL
- Optional: UFW (Ports 80/443 werden bei aktivem UFW automatisch freigegeben)
Script Matrix
Core-Skripte (aktiv)
- gitea.sh
- Start/Stop/Restart/Status für Gitea + Website-Stack
- nginx.sh
- Nginx-Konfiguration anwenden/deaktivieren
- Website/provision_instance.sh
- Instanz-Provisioning für Inventarsystem (release-basiert, Multiinstancing-aware)
- Website/launch_dev.sh
- Dev-Start der Website inkl. Host-Sync
- Website/launch_prod.sh
- Prod-Start der Website inkl. Host-Sync
- Website/start_docker_build.sh
- Build/Start-Helfer für Website-Container
- Website/sync_dev_hosts.sh
- Synchronisiert dynamische Subdomains in /etc/hosts
Setup-Skripte (optional, aktiv)
- setup-first-install.sh
- Führt Erstinstallation in einem Ablauf aus (Start, Nginx, Hosts-Sync-Service, Autostart-Service)
- setup-hosts-sync.sh
- Installiert den systemd-Service für automatische Hosts-Synchronisierung
- setup-stack-autostart.sh
- Installiert den systemd-Service für Stack-Autostart über gitea.sh
Legacy-Skripte (entfernt)
- start-stack-on-boot.sh (durch direkten systemd-ExecStart auf gitea.sh ersetzt)
- provision_instance.sh im Repo-Root (Duplikat, Website-Version ist Single Source)
- Website/run.sh (alt, nicht Teil des aktuellen Flows)
- Website/test.sh (alt, nicht Teil des aktuellen Flows)
Core Betrieb
Docker Services
Datei: gitea.sh
Befehle:
- sudo ./gitea.sh start
- sudo ./gitea.sh stop
- sudo ./gitea.sh restart
- sudo ./gitea.sh status
Wichtige Ports:
- Gitea intern: 127.0.0.1:3001
- Gitea SSH: 2222
- Website Upstream: 4999
Nginx
Datei: nginx.sh
Befehle:
- sudo ./nginx.sh apply
- sudo ./nginx.sh disable
- sudo ./nginx.sh deactivate
Nginx-Templates:
- nginx/gitea.http.conf.template
- nginx/gitea.https.conf.template
- nginx/website.http.conf.template
- nginx/website.https.conf.template
Inventarsystem Instanzen
Admin-Oberfläche:
- Route: /admin/instances
- Menu: Schul-Instanzen
Provisioning-Flow:
- Admin wählt Nutzer, Schule, Version und optional Subdomain.
- Backend ruft Website/provision_instance.sh auf.
- Provisioning installiert release-basiert aus GitHub-Releases.
- Wenn verfügbar, wird docker-compose-multitenant.yml bevorzugt genutzt.
- Instanzstatus wird in school_instances gespeichert.
Wichtige Website-Variablen:
- INSTANCE_REPO_URL (default: https://github.com/AIIrondev/legendary-octo-garbanzo)
- INSTANCE_PARENT_DOMAIN (default: meine-domain)
- INSTANCE_BASE_DIR (default: /opt/inventarsystem-instances)
- INSTANCE_PROVISION_SCRIPT (default: Website/provision_instance.sh)
Berechtigungen für Provisioning:
- Docker-Zugriff
- Schreibrechte auf /etc/nginx/sites-available und /etc/nginx/sites-enabled
- nginx -t und nginx reload/signal-Rechte
Admin Homepage: Live-Logs
Die Admin-Seite unter /admin/system zeigt jetzt Live-Logs direkt im Frontend.
Enthaltene Quellen:
- Core Docker Logs (website + mongodb)
- invario-hosts-sync.service
- invario-stack-autostart.service
- nginx.service
Verhalten:
- Auto-Refresh alle 20 Sekunden
- Manuelles Aktualisieren per Button
- Auswahl der Log-Quelle per Dropdown
Hinweis:
- Wenn die Website ohne Zugriff auf systemd/journalctl läuft (z. B. in eingeschränkten Containern), bleiben Core-Docker-Logs verfügbar, während Service-Logs als nicht verfügbar angezeigt werden können.
Betriebsmodi Website
- Development: Website/launch_dev.sh
- Production: Website/launch_prod.sh
Beispiel Production:
cd Website
export INSTANCE_PARENT_DOMAIN=example.de
export INSTANCE_WILDCARD_CERT_FILE=/etc/nginx/certs/wildcard.example.de.crt
export INSTANCE_WILDCARD_KEY_FILE=/etc/nginx/certs/wildcard.example.de.key
./launch_prod.sh
Empfohlener Ablauf
- sudo ./gitea.sh start
- sudo ./nginx.sh apply
- sudo ./gitea.sh status
Erstinstallation (automatisiert)
Für eine neue Maschine kann die Erstinstallation in einem Schritt ausgeführt werden:
sudo ./setup-first-install.sh
Standardmäßig macht das Skript:
- Startet den Stack über gitea.sh.
- Wendet nginx.sh apply an.
- Installiert den Hosts-Sync-systemd-Service.
- Installiert den Stack-Autostart-systemd-Service.
Optionen:
- --skip-start
- --skip-nginx
- --skip-hosts-sync
- --skip-autostart
Quick Verify
sudo ./gitea.sh status
sudo systemctl status invario-hosts-sync --no-pager
sudo systemctl status invario-stack-autostart --no-pager
Description
Languages
HTML
58.2%
Python
33.6%
JavaScript
6.1%
Shell
1.8%
Dockerfile
0.3%