# docker-compose for local / homelab deployment.
#
# Two usage patterns:
#
#   1. Local MVP test — host network, proxy-DHCP off (don't fight your
#      existing DHCP server on the LAN), TFTP + HTTP exposed on the host:
#
#         docker compose up openpxe-dev
#
#   2. Real PXE deployment — host network, proxy-DHCP on, runs on a box
#      plugged into the PXE network:
#
#         # First set OPENPXE_PUBLIC_IP to this host's LAN address in .env
#         docker compose up openpxe
#
# On Linux hosts, `network_mode: host` gives the container direct access to
# the physical NIC — required for DHCP proxy because CNI overlays and Docker
# bridges do not forward DHCPDISCOVER broadcasts into containers.
#
# On macOS / Windows hosts, `network_mode: host` is limited — the daemon
# runs in a Linux VM (Colima/Docker Desktop) so the "host" network is the
# VM, not your Mac. Proxy-DHCP is not feasible on macOS; use `openpxe-dev`
# with published ports and set DHCP-MODE=disabled.

services:
  # Real PXE deployment (Linux hosts).
  openpxe:
    image: openpxe:0.1.0
    build:
      context: .
      dockerfile: deploy/docker/Dockerfile
    restart: unless-stopped
    network_mode: host
    environment:
      # REQUIRED on multi-homed hosts. Set to this machine's LAN IP so the
      # advertised iPXE URLs actually resolve from the PXE clients. Without
      # this, OpenPXE will refuse to start rather than advertise a
      # loopback address that can't be reached.
      OPENPXE_PUBLIC_IP: ${OPENPXE_PUBLIC_IP:?set this to the host LAN IP}
      OPENPXE_DHCP_MODE: proxy
      OPENPXE_LOG: info
    volumes:
      - ./data/isos:/var/lib/openpxe/isos
      - ./data/work:/var/lib/openpxe/work

  # Dev / MVP container: published ports, DHCP disabled, HTTP on 8080.
  # Use this on laptops where you want to curl the API or UI without
  # running an actual PXE chain.
  openpxe-dev:
    image: openpxe:0.1.0
    build:
      context: .
      dockerfile: deploy/docker/Dockerfile
    environment:
      OPENPXE_PUBLIC_IP: ${OPENPXE_PUBLIC_IP:-127.0.0.1}
      OPENPXE_DHCP_MODE: disabled
      OPENPXE_HTTP_PORT: "8080"
      OPENPXE_TFTP_PORT: "6969"
      OPENPXE_DHCP_PORT: "6767"
      OPENPXE_LOG: info,openpxe=debug
    ports:
      - "8080:8080/tcp"
      - "6969:6969/udp"
    volumes:
      - ./data/isos:/var/lib/openpxe/isos
      - ./data/work:/var/lib/openpxe/work
