version: '3.8'

services:
  metube:
    build: .
    image: metube:latest
    container_name: metube
    restart: unless-stopped
    ports:
      - "8081:8081"
    volumes:
      - ./downloads:/downloads
      - ./metube-config:/config
      # Optional: mount cookies file for authenticated downloads
      # - ./cookies:/cookies:ro
    environment:
      # Basic configuration
      - UID=0
      - GID=0
      - UMASK=022
      
      # Download directories
      - DOWNLOAD_DIR=/downloads
      - STATE_DIR=/config
      - TEMP_DIR=/downloads
      
      # Download behavior
      - DOWNLOAD_MODE=limited
      - MAX_CONCURRENT_DOWNLOADS=3
      - DELETE_FILE_ON_TRASHCAN=true
      
      # Custom directories
      - CUSTOM_DIRS=true
      - CREATE_CUSTOM_DIRS=true
      - CUSTOM_DIRS_EXCLUDE_REGEX=(^|/)[.@].*$
      - DOWNLOAD_DIRS_INDEXABLE=false
      
      # File naming
      - OUTPUT_TEMPLATE=%(title)s.%(ext)s
      - OUTPUT_TEMPLATE_CHAPTER=%(title)s - %(section_number)s %(section_title)s.%(ext)s
      - OUTPUT_TEMPLATE_PLAYLIST=%(playlist_title)s/%(title)s.%(ext)s
      
      # Playlist options
      - DEFAULT_OPTION_PLAYLIST_STRICT_MODE=false
      - DEFAULT_OPTION_PLAYLIST_ITEM_LIMIT=0
      
      # Web server
      - URL_PREFIX=
      - PUBLIC_HOST_URL=download/
      - PUBLIC_HOST_AUDIO_URL=audio_download/
      - HOST=0.0.0.0
      - PORT=8081
      
      # Logging
      - LOGLEVEL=INFO
      - ENABLE_ACCESSLOG=false
      
      # Theme
      - DEFAULT_THEME=auto
      
      # Optional: yt-dlp options
      # - YTDL_OPTIONS={}
      # - YTDL_OPTIONS_FILE=/path/to/ytdl_options.json
      
      # Optional: cookies for authenticated downloads
      # - YTDL_OPTIONS={"cookiefile":"/cookies/cookies.txt"}
      
      # Optional: HTTPS configuration
      # - HTTPS=true
      # - CERTFILE=/ssl/cert.pem
      # - KEYFILE=/ssl/key.pem
      
      # Optional: robots.txt
      # - ROBOTS_TXT=/app/robots.txt

      # MARK_WATCHED_ON_COMPLETE
      - MARK_WATCHED_ON_COMPLETE=true

    # Optional: health check
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8081/version"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

    # Optional: resource limits
    # deploy:
    #   resources:
    #     limits:
    #       cpus: '2.0'
    #       memory: 2G
    #     reservations:
    #       cpus: '0.5'
    #       memory: 512M

# Optional: networks configuration
# networks:
#   default:
#     name: metube-network

# Optional: named volumes
# volumes:
#   metube-downloads:
#     driver: local
#   metube-cookies:
#     driver: local