version: "3.9"

services:
  mclogger-panel:
    build: .
    image: mclogger-panel:latest
    container_name: mclogger-panel
    restart: unless-stopped
    ports:
      - "${PORT:-5000}:5000"
    environment:
      # ── Flask ──────────────────────────────────────────────
      SECRET_KEY: "${SECRET_KEY}"

      # ── Panel-Datenbank (Benutzer / Gruppen) ───────────────
      PANEL_DB_HOST: "${PANEL_DB_HOST:-localhost}"
      PANEL_DB_PORT: "${PANEL_DB_PORT:-3306}"
      PANEL_DB_USER: "${PANEL_DB_USER:-mclogger_panel}"
      PANEL_DB_PASSWORD: "${PANEL_DB_PASSWORD}"
      PANEL_DB_NAME: "${PANEL_DB_NAME:-mclogger_panel}"

      # ── Credentials-Datenbank (verschlüsselte MC-DB-Daten) ─
      CREDS_DB_HOST: "${CREDS_DB_HOST:-localhost}"
      CREDS_DB_PORT: "${CREDS_DB_PORT:-3306}"
      CREDS_DB_USER: "${CREDS_DB_USER:-mclogger_creds}"
      CREDS_DB_PASSWORD: "${CREDS_DB_PASSWORD}"
      CREDS_DB_NAME: "${CREDS_DB_NAME:-mclogger_creds}"

      # ── Sicherheit ──────────────────────────────────────────
      # Fernet-Schlüssel (32 URL-safe base64 bytes):
      # python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
      FERNET_KEY: "${FERNET_KEY}"
      # Pepper für Passwort-Hashing (beliebige lange Zeichenkette)
      PASSWORD_PEPPER: "${PASSWORD_PEPPER}"

      # ── Server ──────────────────────────────────────────────
      HOST: "0.0.0.0"
      PORT: "5000"
      DEBUG: "${DEBUG:-false}"

    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5000/login"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s
