#12 Docker: Dockerfile & docker-compose.yml #12

Open
opened 2026-02-20 23:10:40 +01:00 by ppfeiffer · 0 comments
Owner

Ziel

Das Projekt über docker compose up startbar machen, ohne dass Konfigurationsdateien oder Daten im Image landen.

Dockerfile

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY main.py .
COPY meshbot/ meshbot/
COPY static/ static/
# config/ und data/ werden als Volumes gemountet – NICHT kopieren
RUN useradd -m meshdd && chown -R meshdd:meshdd /app
USER meshdd
EXPOSE 8081
CMD ["python", "main.py"]

Kein COPY config/ – alle lokalen Dateien bleiben außerhalb des Images.

docker-compose.yml

services:
  meshdd:
    build: .
    restart: unless-stopped
    ports:
      - "8081:8081"
    volumes:
      - ./config:/app/config        # config.yaml, scheduler.yaml, nina.yaml
      - ./data:/app/data             # meshdd.db (persistent)
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8081/health')"]
      interval: 30s
      timeout: 5s
      retries: 3

Aufgaben

  • Dockerfile erstellen (non-root user meshdd, kein Config-COPY)
  • docker-compose.yml erstellen mit Bind-Mounts für ./config und ./data
  • .dockerignore erstellen: config/, data/, .git, __pycache__, *.db
  • data/-Verzeichnis mit .gitkeep sicherstellen (Docker muss es beim Start anlegen können)
  • config/config.example.yaml auf v0.09.00 aktualisieren (als Vorlage für Ersteinrichtung)

Akzeptanzkriterium

cp config/config.example.yaml config/config.yaml  # eigene Werte eintragen
docker compose up --build
# → Dashboard erreichbar unter http://localhost:8081
## Ziel Das Projekt über `docker compose up` startbar machen, ohne dass Konfigurationsdateien oder Daten im Image landen. ## Dockerfile ```dockerfile FROM python:3.12-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY main.py . COPY meshbot/ meshbot/ COPY static/ static/ # config/ und data/ werden als Volumes gemountet – NICHT kopieren RUN useradd -m meshdd && chown -R meshdd:meshdd /app USER meshdd EXPOSE 8081 CMD ["python", "main.py"] ``` Kein `COPY config/` – alle lokalen Dateien bleiben außerhalb des Images. ## docker-compose.yml ```yaml services: meshdd: build: . restart: unless-stopped ports: - "8081:8081" volumes: - ./config:/app/config # config.yaml, scheduler.yaml, nina.yaml - ./data:/app/data # meshdd.db (persistent) healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8081/health')"] interval: 30s timeout: 5s retries: 3 ``` ## Aufgaben - [ ] `Dockerfile` erstellen (non-root user `meshdd`, kein Config-COPY) - [ ] `docker-compose.yml` erstellen mit Bind-Mounts für `./config` und `./data` - [ ] `.dockerignore` erstellen: `config/`, `data/`, `.git`, `__pycache__`, `*.db` - [ ] `data/`-Verzeichnis mit `.gitkeep` sicherstellen (Docker muss es beim Start anlegen können) - [ ] `config/config.example.yaml` auf v0.09.00 aktualisieren (als Vorlage für Ersteinrichtung) ## Akzeptanzkriterium ```bash cp config/config.example.yaml config/config.yaml # eigene Werte eintragen docker compose up --build # → Dashboard erreichbar unter http://localhost:8081 ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ppfeiffer/MeshDD-Bot#12
No description provided.