# ============================================================================
# Palworld Proton Docker Server - Docker Compose
# Windows Dedicated Server via Proton-GE unter Linux
# ============================================================================

version: "3.8"

services:
  palworld-proton:
    build:
      context: ./docker
      dockerfile: Dockerfile
      args:
        PROTON_VERSION: GE-Proton9-20
        STEAM_APP_ID: 2394010
    image: palworld-proton:latest
    container_name: palworld-proton-server
    hostname: palworld-server
    restart: unless-stopped
    
    # Ressourcen-Limits (optional, anpassen je nach Server-Größe)
    deploy:
      resources:
        limits:
          cpus: '4'
          memory: 16G
        reservations:
          cpus: '2'
          memory: 8G
    
    # Umgebungsvariablen aus .env Datei oder direkt hier
    env_file:
      - config/default.env
    # ODER direkte Definition:
    # environment:
    #   - SERVER_NAME=Mein Palworld Server
    #   - MAX_PLAYERS=32
    
    # Ports
    # 8211: Haupt-Game-Port (UDP/TCP)
    # 27015: Steam Query Port (UDP)
    # 25575: RCON Port (TCP)
    # 8212: REST API Port (TCP) - optional
    ports:
      - "8211:8211/tcp"
      - "8211:8211/udp"
      - "27015:27015/udp"
      - "25575:25575/tcp"
      - "8212:8212/tcp"
    
    # Volumes für Persistenz
    volumes:
      # Server-Dateien (Steam-Installation)
      - ./data/server:/opt/palworld/server
      # Konfigurations-Dateien
      - ./data/config:/opt/palworld/config
      # Backups
      - ./data/backups:/opt/palworld/backups
      # Mods (optional)
      - ./data/mods:/opt/palworld/mods
    
    # Logging
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "5"
    
    # Healthcheck
    healthcheck:
      test: ["/opt/palworld/scripts/healthcheck.sh"]
      interval: 60s
      timeout: 10s
      retries: 3
      start_period: 300s
    
    # Sicherheit
    security_opt:
      - no-new-privileges:true
    
    # Capabilities (minimiert)
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID

# ============================================================================
# Optional: Separate Backup-Volume
# ============================================================================
volumes:
  palworld-server:
    driver: local
  palworld-config:
    driver: local
  palworld-backups:
    driver: local
  palworld-mods:
    driver: local
