# Keine festen container_name — Compose-Namen haben Projektprefix (<projekt>-postgres-1).
# Medien: In .env SHINKAN_MEDIA_HOST (Host-Pfad) und optional MEDIA_ROOT (Container-Pfad) setzen.
# Default Host /shinkan-media/dev — Verzeichnis ggf. anlegen oder Compose legt es an.

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: "${DB_NAME:-shinkan_dev}"
      POSTGRES_USER: "${DB_USER:-shinkan_dev}"
      POSTGRES_PASSWORD: "${DB_PASSWORD:-dev_password}"
    volumes:
      - dev-shinkan-db-data:/var/lib/postgresql/data
    ports:
      - "5435:5432"
    restart: unless-stopped
    networks:
      - dev-shinkan-network

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    environment:
      DB_HOST: postgres
      DB_PORT: 5432
      DB_NAME: "${DB_NAME:-shinkan_dev}"
      DB_USER: "${DB_USER:-shinkan_dev}"
      DB_PASSWORD: "${DB_PASSWORD:-dev_password}"
      OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
      OPENROUTER_MODEL: ${OPENROUTER_MODEL}
      SMTP_HOST: ${SMTP_HOST}
      SMTP_PORT: ${SMTP_PORT}
      SMTP_USER: ${SMTP_USER}
      SMTP_PASS: ${SMTP_PASS}
      SMTP_FROM: ${SMTP_FROM}
      APP_URL: "${APP_URL:-https://dev.shinkan.jinkendo.de}"
      ALLOWED_ORIGINS: "${ALLOWED_ORIGINS:-https://dev.shinkan.jinkendo.de,http://192.168.2.49:3098}"
      ENVIRONMENT: "${ENVIRONMENT:-development}"
      MEDIAWIKI_API_URL: "${MEDIAWIKI_API_URL:-https://karatetrainer.net/api.php}"
      MEDIAWIKI_USER: "${MEDIAWIKI_USER:-Jinkendo}"
      MEDIAWIKI_PASSWORD: "${MEDIAWIKI_PASSWORD:-CHANGE_ME}"
      MEDIAWIKI_CATEGORY_EXERCISES: "${MEDIAWIKI_CATEGORY_EXERCISES:-Übungen}"
      MEDIAWIKI_CATEGORY_SKILLS: "${MEDIAWIKI_CATEGORY_SKILLS:-Fähigkeitsbeschreibung}"
      MEDIAWIKI_CATEGORY_METHODS: "${MEDIAWIKI_CATEGORY_METHODS:-Methodenbeschreibung}"
      MEDIAWIKI_CATEGORY_MODELS: "${MEDIAWIKI_CATEGORY_MODELS:-Reifegradmodelle}"
      MEDIA_ROOT: "${MEDIA_ROOT:-/app/media}"
    volumes:
      - ${SHINKAN_MEDIA_HOST:-/shinkan-media/dev}:${MEDIA_ROOT:-/app/media}
    ports:
      - "8098:8000"
    depends_on:
      - postgres
    restart: unless-stopped
    networks:
      - dev-shinkan-network

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      # Leer = relative /api/*-URLs → gleicher Host wie die SPA (vermeidet Mixed Content HTTPS→HTTP)
      args:
        VITE_API_URL: ""
    ports:
      - "3098:80"
    depends_on:
      - backend
    restart: unless-stopped
    networks:
      - dev-shinkan-network

volumes:
  dev-shinkan-db-data:

networks:
  dev-shinkan-network:
    driver: bridge
