feat: Docker-Integration hinzugefügt - Dockerfile, docker-compose.yml und .dockerignore erstellt - README.md mit umfassender Docker-Dokumentation erweitert - Multi-Service-Architektur für Hauptservice und Statistik-Service - Lokale Volume-Mappings für .env und .json Dateien - Vollständige Docker-Handhabung dokumentiert
This commit is contained in:
49
.dockerignore
Normal file
49
.dockerignore
Normal file
@ -0,0 +1,49 @@
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Python
|
||||
__pycache__
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.Python
|
||||
env
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
.tox
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.log
|
||||
.git
|
||||
.mypy_cache
|
||||
.pytest_cache
|
||||
.hypothesis
|
||||
|
||||
# Docker
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
.dockerignore
|
||||
|
||||
# Dokumentation
|
||||
README*.md
|
||||
LICENSE.txt
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Lokale Konfiguration und Daten
|
||||
.env
|
||||
*.json
|
||||
*.cmd
|
||||
19
Dockerfile
19
Dockerfile
@ -1,11 +1,26 @@
|
||||
# Dockerfile für TI-Status2Mattermost
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt ./
|
||||
# System-Abhängigkeiten installieren
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Python-Abhängigkeiten kopieren und installieren
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
# Anwendungsdateien kopieren
|
||||
COPY ti_status_checker.py .
|
||||
COPY ti_statistics.py .
|
||||
|
||||
# Nicht-root Benutzer erstellen
|
||||
RUN useradd --create-home --shell /bin/bash appuser && \
|
||||
chown -R appuser:appuser /app
|
||||
USER appuser
|
||||
|
||||
# Standardbefehl
|
||||
CMD ["python", "ti_status_checker.py"]
|
||||
153
README.md
153
README.md
@ -17,6 +17,8 @@ Ein Python-Skript, das den TI-Status überwacht und neue Meldungen über Apprise
|
||||
|
||||
## Installation
|
||||
|
||||
### Option 1: Lokale Python-Installation
|
||||
|
||||
1. Repository klonen:
|
||||
```bash
|
||||
git clone https://gitea.medisoftware.org/Markus/TI-Status2Mattermost.git
|
||||
@ -37,6 +39,23 @@ source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Option 2: Docker (Empfohlen)
|
||||
|
||||
1. Repository klonen:
|
||||
```bash
|
||||
git clone https://gitea.medisoftware.org/Markus/TI-Status2Mattermost.git
|
||||
cd TI-Status2Mattermost
|
||||
```
|
||||
|
||||
2. Docker und Docker Compose installieren (falls noch nicht vorhanden)
|
||||
|
||||
3. Konfiguration einrichten (siehe Abschnitt "Konfiguration")
|
||||
|
||||
4. Container starten:
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
## Konfiguration
|
||||
|
||||
1. Kopiere die Beispiel-Konfiguration:
|
||||
@ -97,13 +116,112 @@ DEBUG_MODE=true
|
||||
|
||||
Weitere Apprise-URLs findest du in der [Apprise-Dokumentation](https://github.com/caronc/apprise#supported-notifications).
|
||||
|
||||
## Docker-Architektur
|
||||
|
||||
### Services
|
||||
|
||||
#### ti-status-checker
|
||||
- **Hauptservice** für die kontinuierliche Überwachung der TI-Status-API
|
||||
- Läuft dauerhaft und prüft regelmäßig auf neue Meldungen
|
||||
- Sendet Benachrichtigungen bei Änderungen
|
||||
- Zeichnet Störungen in der Statistik auf
|
||||
|
||||
#### ti-statistics
|
||||
- **Statistik-Service** für periodische Berichte
|
||||
- Kann manuell oder automatisch ausgeführt werden
|
||||
- Generiert und sendet detaillierte Ausfall-Statistiken
|
||||
- Läuft unabhängig vom Hauptservice
|
||||
|
||||
### Volume-Mappings
|
||||
|
||||
Alle wichtigen Dateien werden als lokale Volumes eingebunden:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
# Konfiguration (read-only)
|
||||
- ./.env:/app/.env:ro
|
||||
|
||||
# Persistierte Daten
|
||||
- ./ti_status_state.json:/app/ti_status_state.json
|
||||
- ./ti_outage_statistics.json:/app/ti_outage_statistics.json
|
||||
```
|
||||
|
||||
**Vorteile:**
|
||||
- ✅ Daten bleiben auf dem lokalen System
|
||||
- ✅ Einfache Updates ohne Datenverlust
|
||||
- ✅ Backup der Konfiguration und Daten möglich
|
||||
- ✅ Debugging und Monitoring von außen
|
||||
|
||||
### Netzwerk
|
||||
|
||||
- Isoliertes Docker-Netzwerk `ti-status-network`
|
||||
- Services können untereinander kommunizieren
|
||||
- Externe Verbindungen nur für API-Calls und Benachrichtigungen
|
||||
|
||||
### Umgebungsvariablen
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- DBG_MODE=false # Kann in .env überschrieben werden
|
||||
```
|
||||
|
||||
### Automatischer Restart
|
||||
|
||||
```yaml
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
- Container startet automatisch nach Neustart des Hosts
|
||||
- Bei Fehlern wird der Container neu gestartet
|
||||
- Nur bei manuellem Stopp bleibt der Container gestoppt
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Hauptskript ausführen:
|
||||
### Mit lokaler Python-Installation
|
||||
|
||||
#### Hauptskript ausführen:
|
||||
```bash
|
||||
python ti_status_checker.py
|
||||
```
|
||||
|
||||
### Mit Docker
|
||||
|
||||
#### Container starten:
|
||||
```bash
|
||||
# Alle Services starten
|
||||
docker-compose up --build
|
||||
|
||||
# Nur den Hauptservice starten
|
||||
docker-compose up ti-status-checker
|
||||
|
||||
# Im Hintergrund laufen lassen
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
#### Container verwalten:
|
||||
```bash
|
||||
# Logs anzeigen
|
||||
docker-compose logs -f ti-status-checker
|
||||
|
||||
# Container stoppen
|
||||
docker-compose down
|
||||
|
||||
# Container neu starten
|
||||
docker-compose restart ti-status-checker
|
||||
|
||||
# Status anzeigen
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
#### Statistik-Service:
|
||||
```bash
|
||||
# Nur Statistik-Bericht senden
|
||||
docker-compose run --rm ti-statistics
|
||||
|
||||
# Statistik-Service dauerhaft starten
|
||||
docker-compose up ti-statistics
|
||||
```
|
||||
|
||||
### Verbindungstest:
|
||||
```bash
|
||||
python test_apprise.py
|
||||
@ -128,12 +246,23 @@ Das Skript gibt dann detaillierte Debug-Informationen aus:
|
||||
- Benachrichtigungsregeln-Auswertung
|
||||
- Endpunkt-Status
|
||||
|
||||
### Für kontinuierliche Überwachung (z.B. mit cron):
|
||||
### Für kontinuierliche Überwachung
|
||||
|
||||
#### Mit lokaler Python-Installation (cron):
|
||||
```bash
|
||||
# Alle 5 Minuten ausführen
|
||||
*/5 * * * * cd /path/to/TI-Status2Mattermost && python ti_status_checker.py
|
||||
```
|
||||
|
||||
#### Mit Docker (automatischer Restart):
|
||||
```bash
|
||||
# Container läuft dauerhaft und startet automatisch neu
|
||||
docker-compose up -d
|
||||
|
||||
# Für periodische Ausführung alle 5 Minuten (in docker-compose.yml aktivieren):
|
||||
# command: ["sh", "-c", "while true; do python ti_status_checker.py; sleep 300; done"]
|
||||
```
|
||||
|
||||
## Benachrichtigungsregeln
|
||||
|
||||
### Filter
|
||||
@ -163,15 +292,33 @@ Apprise unterstützt über 80 verschiedene Benachrichtigungsdienste, darunter:
|
||||
|
||||
## Dateien
|
||||
|
||||
### Anwendung
|
||||
- `ti_status_checker.py` - Hauptskript mit Multi-Endpoint-Support
|
||||
- `ti_statistics.py` - Statistik-Funktionalität für Störungen
|
||||
- `test_apprise.py` - Umfassendes Test-Tool für alle Endpunkte
|
||||
|
||||
### Konfiguration
|
||||
- `requirements.txt` - Python-Abhängigkeiten (python-dotenv, apprise)
|
||||
- `env.example` - Beispiel-Konfiguration mit allen Optionen
|
||||
- `ti_status_state.json` - Lokale Statusverfolgung (wird automatisch erstellt)
|
||||
- `.env` - Deine Konfiguration (nicht im Repository)
|
||||
|
||||
### Docker
|
||||
- `Dockerfile` - Container-Image für die Anwendung
|
||||
- `docker-compose.yml` - Multi-Service-Orchestrierung
|
||||
- `.dockerignore` - Dateien die vom Docker Build ausgeschlossen werden
|
||||
|
||||
### Daten
|
||||
- `ti_status_state.json` - Lokale Statusverfolgung (wird automatisch erstellt)
|
||||
- `ti_outage_statistics.json` - Statistik-Daten der Störungen (wird automatisch erstellt)
|
||||
|
||||
## Changelog
|
||||
|
||||
### Version 3.1 (Docker-Support)
|
||||
- ✅ Vollständige Docker-Integration mit Dockerfile und docker-compose.yml
|
||||
- ✅ Multi-Service-Architektur (Hauptservice + Statistik-Service)
|
||||
- ✅ Lokale Volume-Mappings für .env und .json Dateien
|
||||
- ✅ Automatischer Restart und Container-Management
|
||||
|
||||
### Version 3.0 (Multi-Endpoint & Rules)
|
||||
- ✅ Mehrere Apprise-Endpunkte gleichzeitig
|
||||
- ✅ Konfigurierbare Benachrichtigungsregeln (Filter, Zeiten, Verzögerungen)
|
||||
|
||||
46
docker-compose.yml
Normal file
46
docker-compose.yml
Normal file
@ -0,0 +1,46 @@
|
||||
services:
|
||||
ti-status-checker:
|
||||
build: .
|
||||
container_name: ti-status-checker
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
# .env Datei für Konfiguration
|
||||
- ./.env:/app/.env:ro
|
||||
# JSON-Dateien für Persistierung
|
||||
- ./ti_status_state.json:/app/ti_status_state.json
|
||||
- ./ti_outage_statistics.json:/app/ti_outage_statistics.json
|
||||
environment:
|
||||
# Debug-Modus (kann in .env überschrieben werden)
|
||||
- DBG_MODE=false
|
||||
networks:
|
||||
- ti-status-network
|
||||
# Optional: Cron-ähnliche Ausführung alle 5 Minuten
|
||||
# command: ["sh", "-c", "while true; do python ti_status_checker.py; sleep 300; done"]
|
||||
|
||||
# Optional: Statistik-Service der täglich läuft
|
||||
ti-statistics:
|
||||
build: .
|
||||
container_name: ti-statistics
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./.env:/app/.env:ro
|
||||
- ./ti_outage_statistics.json:/app/ti_outage_statistics.json
|
||||
command: ["python", "ti_status_checker.py", "--stats"]
|
||||
environment:
|
||||
- DBG_MODE=false
|
||||
networks:
|
||||
- ti-status-network
|
||||
# Läuft einmal täglich um 8:00 Uhr
|
||||
# depends_on:
|
||||
# - ti-status-checker
|
||||
|
||||
networks:
|
||||
ti-status-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
# Lokale Volumes für Persistierung
|
||||
ti-status-state:
|
||||
driver: local
|
||||
ti-outage-statistics:
|
||||
driver: local
|
||||
Reference in New Issue
Block a user