services:
  ledgrab:
    build:
      context: .
      dockerfile: Dockerfile
    image: ledgrab:latest
    container_name: ledgrab
    restart: unless-stopped

    ports:
      - "${LEDGRAB_PORT:-8080}:8080"

    volumes:
      # Persist device data and configuration across restarts
      - ./data:/app/data
      - ./logs:/app/logs
      # Mount configuration for easy editing without rebuild
      - ./config:/app/config:ro
      # Required for screen capture on Linux (X11)
      - /tmp/.X11-unix:/tmp/.X11-unix:ro

    environment:
      ## Server
      # Bind address and port (usually no need to change)
      - LEDGRAB_SERVER__HOST=0.0.0.0
      - LEDGRAB_SERVER__PORT=8080
      - LEDGRAB_SERVER__LOG_LEVEL=INFO
      # CORS origins — add your LAN IP for remote access, e.g.:
      #   LEDGRAB_SERVER__CORS_ORIGINS=["http://localhost:8080","http://192.168.1.100:8080"]

      ## Auth
      # Override the default API key (STRONGLY recommended for production):
      #   LEDGRAB_AUTH__API_KEYS__main=your-secure-key-here
      # Generate a key: openssl rand -hex 32

      ## Display (Linux X11 only)
      - DISPLAY=${DISPLAY:-:0}

      ## Processing defaults
      #- LEDGRAB_PROCESSING__DEFAULT_FPS=30
      #- LEDGRAB_PROCESSING__BORDER_WIDTH=10

      ## MQTT (optional — for Home Assistant auto-discovery)
      #- LEDGRAB_MQTT__ENABLED=true
      #- LEDGRAB_MQTT__BROKER_HOST=192.168.1.2
      #- LEDGRAB_MQTT__BROKER_PORT=1883
      #- LEDGRAB_MQTT__USERNAME=
      #- LEDGRAB_MQTT__PASSWORD=

    # Uncomment for Linux screen capture (requires host network for X11 access)
    # network_mode: host

    networks:
      - ledgrab-network

networks:
  ledgrab-network:
    driver: bridge
