version: '3.8'

services:
  pufferpanel:
    image: pufferpanel/pufferpanel:latest
    container_name: pufferpanel
    restart: unless-stopped

    environment:
      - PUFFER_WEB_HOST=0.0.0.0:8080
      - PUFFER_DAEMON_SFTP_HOST=0.0.0.0:5657
      - PUFFER_DAEMON_DATA_FOLDER=/var/lib/pufferpanel
      - PUFFER_DAEMON_CONSOLE_BUFFER=50
      - PUFFER_DAEMON_CONSOLE_FORWARD=false
      - PUFFER_LOGS_LEVEL=INFO
      - PUFFER_WEB_SESSION_KEY=changeme-generate-random-key
      - TZ=America/Los_Angeles

    ports:
      - "8080:8080"     # Web interface
      - "5657:5657"     # SFTP server

    volumes:
      # Configuration and data
      - pufferpanel-config:/etc/pufferpanel
      - pufferpanel-data:/var/lib/pufferpanel
      - pufferpanel-logs:/var/log/pufferpanel

      # Docker socket for container management (if needed)
      - /var/run/docker.sock:/var/run/docker.sock:ro

      # Game server files (optional, for direct file access)
      - pufferpanel-servers:/var/lib/pufferpanel/servers

    networks:
      - pufferpanel-network

    # Security context
    user: "1000:1000"

    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M

    # Health check
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/api/self"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

    # Logging configuration
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

networks:
  pufferpanel-network:
    driver: bridge

volumes:
  pufferpanel-config:
    driver: local
  pufferpanel-data:
    driver: local
  pufferpanel-logs:
    driver: local
  pufferpanel-servers:
    driver: local

# Note: This is a reference Docker Compose configuration.
# The current installation runs as a system service.
# To migrate to Docker:
# 1. Stop the system service: sudo systemctl stop pufferpanel
# 2. Backup current data: sudo cp -r /var/lib/pufferpanel /backup/
# 3. Update this configuration with your specific settings
# 4. Run: docker-compose up -d
# 5. Restore data if needed
