# mDNS toggle — publish *.local service names via the HOST's avahi-daemon for
# zero-config guest resolution. Enabled when ENABLE_MDNS=true in .env and only
# meaningful when BASE_DOMAIN=*.local.
#
# Host prerequisites:
#   - avahi-daemon running on the host
#   - if the host has many interfaces (e.g. lots of docker bridges), restrict
#     avahi to the LAN NIC in /etc/avahi/avahi-daemon.conf:
#         allow-interfaces=<lan-iface>
#     otherwise avahi sees its own announcements across bridges → "Local name
#     collision" and publishing fails.
services:
  avahi:
    build: ./docker/avahi
    image: ulicraft-avahi:local
    container_name: avahi
    restart: unless-stopped
    network_mode: host
    # AppArmor's docker-default profile blocks the D-Bus publish to host avahi.
    security_opt:
      - apparmor=unconfined
    environment:
      BASE_DOMAIN: ${BASE_DOMAIN}
      HOST_LAN_IP: ${HOST_LAN_IP}
      DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/run/dbus/system_bus_socket"
    volumes:
      # Talk to the host's avahi-daemon (host must run avahi-daemon).
      - /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
