# Dragon Fork WebRTC PoC — TrueNAS deployment template.
#
# Host networking is required: WebRTC ICE needs each container-visible
# UDP socket to be reachable from the peer using the LAN (or public)
# IP advertised in SDP. Bridge + port mapping breaks ICE because
# remote candidates encode the peer-visible host:port.
#
# Copy this file to /mnt/NVME/Docker/dragonfork-webrtc-poc/
# alongside a .env like:
#
#   WHEP_PORT=45121     # TCP, the WHEP HTTP listener
#   RTP_PORT=49248      # UDP, publisher's RTP ingest port
#   STREAM_ID=test
#   PUBLIC_IP=10.0.0.25 # LAN IP; rewrites ICE host candidates via NAT1To1.
#                        Set to your public IP when exposing externally.
#
# Then:
#   docker compose up -d --build

services:
  webrtc-poc:
    build:
      context: ../..                     # repo root (where go.mod lives)
      dockerfile: deploy/docker/Dockerfile
    container_name: dragonfork-webrtc-poc
    restart: unless-stopped
    network_mode: host
    command:
      - -stream=${STREAM_ID:-test}
      - -rtp-host=${RTP_HOST:-0.0.0.0}
      - -rtp-port=${RTP_PORT:?set RTP_PORT}
      - -listen=:${WHEP_PORT:?set WHEP_PORT}
      - -public-ip=${PUBLIC_IP:-}
    # No ports: host networking exposes whatever the process binds.
    # No healthcheck: scratch image has no shell. Compose uses exit
    # code only; the binary exits non-zero if it can't bind.
