Dockerized
This commit is contained in:
77
.dockerignore
Normal file
77
.dockerignore
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# Docker Ignore Datei für CameraSave
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Bereits vorhandene Videos sollen nicht ins Image
|
||||||
|
videospeicher/
|
||||||
13
.env.example
Normal file
13
.env.example
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Umgebungsvariablen für CameraSave Docker Container
|
||||||
|
# Kopiere diese Datei zu .env und passe die Werte an
|
||||||
|
|
||||||
|
# IMAP Server Konfiguration
|
||||||
|
IMAP_SERVER=secureimap.t-online.de
|
||||||
|
IMAP_PORT=993
|
||||||
|
|
||||||
|
# E-Mail Anmeldedaten (SICHERHEITSHINWEIS: Verwende App-spezifische Passwörter!)
|
||||||
|
EMAIL_USER=dk2ge@t-online.de
|
||||||
|
EMAIL_PASS=ETBjw65tf2
|
||||||
|
|
||||||
|
# Speicherverzeichnis (Container-intern)
|
||||||
|
SAVE_DIR=/app/videospeicher
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,9 @@
|
|||||||
# Projekt-Sachen
|
# Projekt-Sachen
|
||||||
videospeicher/
|
videospeicher/
|
||||||
|
|
||||||
|
# === Docker ===
|
||||||
|
.env
|
||||||
|
|
||||||
# === Python Bytecode ===
|
# === Python Bytecode ===
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Verwende Python 3.11 als Basis-Image
|
||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
# Setze Arbeitsverzeichnis
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Kopiere requirements.txt und installiere Dependencies
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Kopiere den Anwendungscode
|
||||||
|
COPY main.py .
|
||||||
|
|
||||||
|
# Erstelle Verzeichnis für Videospeicher
|
||||||
|
RUN mkdir -p /app/videospeicher
|
||||||
|
|
||||||
|
# Setze Umgebungsvariablen
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Definiere Volume für persistente Datenspeicherung
|
||||||
|
VOLUME ["/app/videospeicher"]
|
||||||
|
|
||||||
|
# Führe das Skript aus
|
||||||
|
CMD ["python", "main.py"]
|
||||||
126
README.md
Normal file
126
README.md
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
# CameraSave Docker Container
|
||||||
|
|
||||||
|
Ein Python-Skript, das automatisch Video-Anhänge aus E-Mails herunterlädt und in einer strukturierten Ordnerhierarchie speichert.
|
||||||
|
|
||||||
|
## 🚀 Schnellstart mit Docker
|
||||||
|
|
||||||
|
### 1. Repository klonen/vorbereiten
|
||||||
|
```bash
|
||||||
|
cd /Users/rxf/Projekte/CameraSave
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Umgebungsvariablen konfigurieren (optional)
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
# Bearbeite .env mit deinen E-Mail-Zugangsdaten
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Container mit Docker Compose starten
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Logs überprüfen
|
||||||
|
```bash
|
||||||
|
docker-compose logs -f camerasave
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🐋 Manuelle Docker-Befehle
|
||||||
|
|
||||||
|
### Image erstellen
|
||||||
|
```bash
|
||||||
|
docker build -t camerasave .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Container ausführen
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
--name camerasave \
|
||||||
|
-v $(pwd)/videospeicher:/app/videospeicher \
|
||||||
|
-e EMAIL_USER="deine-email@domain.de" \
|
||||||
|
-e EMAIL_PASS="dein-passwort" \
|
||||||
|
camerasave
|
||||||
|
```
|
||||||
|
|
||||||
|
### Einmalige Ausführung
|
||||||
|
```bash
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/videospeicher:/app/videospeicher \
|
||||||
|
-e EMAIL_USER="deine-email@domain.de" \
|
||||||
|
-e EMAIL_PASS="dein-passwort" \
|
||||||
|
camerasave
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 Ordnerstruktur
|
||||||
|
|
||||||
|
Das Skript erstellt automatisch folgende Struktur:
|
||||||
|
```
|
||||||
|
videospeicher/
|
||||||
|
├── 2025/
|
||||||
|
│ ├── 01/
|
||||||
|
│ │ ├── 15/
|
||||||
|
│ │ │ ├── 01_20250115123456000.mp4
|
||||||
|
│ │ │ └── ...
|
||||||
|
│ │ └── ...
|
||||||
|
│ └── ...
|
||||||
|
└── ...
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚙️ Konfiguration
|
||||||
|
|
||||||
|
### Umgebungsvariablen
|
||||||
|
- `IMAP_SERVER`: IMAP-Server (Standard: secureimap.t-online.de)
|
||||||
|
- `IMAP_PORT`: IMAP-Port (Standard: 993)
|
||||||
|
- `EMAIL_USER`: E-Mail-Adresse
|
||||||
|
- `EMAIL_PASS`: E-Mail-Passwort (empfohlen: App-spezifisches Passwort)
|
||||||
|
- `SAVE_DIR`: Speicherverzeichnis (Standard: /app/videospeicher)
|
||||||
|
|
||||||
|
### Automatische Bereinigung
|
||||||
|
- Dateien älter als 365 Tage werden automatisch gelöscht
|
||||||
|
- Leere Ordner werden entfernt
|
||||||
|
|
||||||
|
## 🔒 Sicherheitshinweise
|
||||||
|
|
||||||
|
1. **App-spezifische Passwörter verwenden**: Erstelle ein App-spezifisches Passwort für dein E-Mail-Konto
|
||||||
|
2. **Umgebungsvariablen nutzen**: Speichere Zugangsdaten nicht im Code
|
||||||
|
3. **Volume-Backups**: Sichere regelmäßig das `videospeicher` Volume
|
||||||
|
|
||||||
|
## 🛠 Wartung
|
||||||
|
|
||||||
|
### Container neustarten
|
||||||
|
```bash
|
||||||
|
docker-compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
### Container stoppen
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logs anzeigen
|
||||||
|
```bash
|
||||||
|
docker-compose logs camerasave
|
||||||
|
```
|
||||||
|
|
||||||
|
### Container-Status prüfen
|
||||||
|
```bash
|
||||||
|
docker-compose ps
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🐛 Troubleshooting
|
||||||
|
|
||||||
|
### E-Mail-Verbindungsfehler
|
||||||
|
- Überprüfe IMAP-Server und Port
|
||||||
|
- Stelle sicher, dass IMAP aktiviert ist
|
||||||
|
- Verwende App-spezifische Passwörter
|
||||||
|
|
||||||
|
### Berechtigung-Fehler
|
||||||
|
```bash
|
||||||
|
# Berechtigungen für videospeicher-Ordner setzen
|
||||||
|
sudo chown -R $(id -u):$(id -g) videospeicher/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Container-Logs überprüfen
|
||||||
|
```bash
|
||||||
|
docker logs camerasave
|
||||||
|
```
|
||||||
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
camerasave:
|
||||||
|
build: .
|
||||||
|
container_name: camerasave
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./videospeicher:/app/videospeicher
|
||||||
|
environment:
|
||||||
|
# Überschreibe hier die E-Mail-Konfiguration wenn nötig
|
||||||
|
- IMAP_SERVER=secureimap.t-online.de
|
||||||
|
- IMAP_PORT=993
|
||||||
|
- EMAIL_USER=dk2ge@t-online.de
|
||||||
|
- EMAIL_PASS=ETBjw65tf2
|
||||||
|
# Führe das Skript alle 5 Minuten aus
|
||||||
|
command: >
|
||||||
|
sh -c "while true; do
|
||||||
|
python main.py && echo 'CameraSave ausgeführt um $$(date)' && sleep 300;
|
||||||
|
done"
|
||||||
10
main.py
10
main.py
@@ -5,11 +5,11 @@ import shutil
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
# === KONFIGURATION ===
|
# === KONFIGURATION ===
|
||||||
IMAP_SERVER = "secureimap.t-online.de"
|
IMAP_SERVER = os.getenv("IMAP_SERVER", "secureimap.t-online.de")
|
||||||
IMAP_PORT = 993
|
IMAP_PORT = int(os.getenv("IMAP_PORT", "993"))
|
||||||
EMAIL_USER = "dk2ge@t-online.de"
|
EMAIL_USER = os.getenv("EMAIL_USER", "dk2ge@t-online.de")
|
||||||
EMAIL_PASS = "ETBjw65tf2"
|
EMAIL_PASS = os.getenv("EMAIL_PASS", "ETBjw65tf2")
|
||||||
SAVE_DIR = "./videospeicher"
|
SAVE_DIR = os.getenv("SAVE_DIR", "./videospeicher")
|
||||||
|
|
||||||
# === ALTE DATEIEN LÖSCHEN (älter als 1 Jahr) ===
|
# === ALTE DATEIEN LÖSCHEN (älter als 1 Jahr) ===
|
||||||
def cleanup_old_files(base_dir, days=365):
|
def cleanup_old_files(base_dir, days=365):
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Keine externen Dependencies erforderlich
|
||||||
|
# Das Skript verwendet nur Python Standard-Bibliotheken:
|
||||||
|
# - imaplib (E-Mail IMAP-Zugriff)
|
||||||
|
# - email (E-Mail-Parsing)
|
||||||
|
# - os (Dateisystem-Operationen)
|
||||||
|
# - shutil (Datei-/Ordner-Operationen)
|
||||||
|
# - datetime (Datum/Zeit-Operationen)
|
||||||
Reference in New Issue
Block a user