# moonlight-web-stream - https://github.com/MrCreativ3001/moonlight-web-stream
services:
  # Session 1: Connecting to your current Ubuntu VM (apollo)
  moonlight-apollo:
    image: mrcreativ3001/moonlight-web-stream:latest
    container_name: moonlight_gateway_apollo
    restart: unless-stopped
    network_mode: host  # Bypasses Docker bridge networking
    volumes:
    # FIXED: Reverted to the original mount path. If the app auto-writes settings, 
    # it can put them here, but our environment variables will override the port.    
    - ./config/apollo:/app/config
    environment:
      # FIX: The binary explicitly looks for BIND_ADDRESS to overwrite the listener
      - BIND_ADDRESS=0.0.0.0:${MOONLIGHT_PORT}
      # FIX: Use the binary's exact env hook to set the WebRTC port ranges cleanly
      - WEBRTC_PORT_RANGE=40000:40010
      # FIX: Forces WebRTC to tell your browser exactly where to send the UDP packets
      - WEBRTC_NAT_1TO1_HOST=${DOCKER_HOST_IP}
    labels:
      # Nginx Proxy Manager Automation
      - "npm.proxy.domains=moonlight.wompmacho.com"
      - "npm.proxy.host=${DOCKER_HOST_IP}"
      - "npm.proxy.port=${MOONLIGHT_PORT}" 
      - "npm.proxy.scheme=http"
      - "npm.proxy.ssl_verify=false"
      - "npm.proxy.websockets=true"
      - "npm.proxy.ssl.force=true"
      - "npm.proxy.ssl.certificate.id=2"
      # FIXED: Inject Custom Nginx Performance Directives via Labels
      - "npm.advanced=proxy_http_version 1.1; proxy_set_header Upgrade $$http_upgrade; proxy_set_header Connection \"Upgrade\"; proxy_connect_timeout 7d; proxy_send_timeout 7d; proxy_read_timeout 7d; proxy_buffering off; proxy_request_buffering off; chunked_transfer_encoding on; client_max_body_size 0;"
      # Pi-hole Automation (Point to Docker Host/Proxy IP)
      - "pihole.custom-record=[[\"moonlight.wompmacho.com\", \"${DOCKER_HOST_IP}\"]]"