x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  dnsmasq:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}dockurr/dnsmasq:${DNSMASQ_VERSION:-2.91}
    volumes:
      - ./dnsmasq.conf:/etc/dnsmasq.conf:ro
    ports:
      - '${DNSMASQ_DNS_PORT_OVERRIDE:-53}:53/udp'
      - '${DNSMASQ_DNS_PORT_OVERRIDE:-53}:53/tcp'
    environment:
      - TZ=${TZ:-UTC}
    cap_drop:
      - ALL
    cap_add:
      - NET_ADMIN
      - NET_BIND_SERVICE
    healthcheck:
      test: [CMD, nslookup, -timeout=1, localhost, 127.0.0.1]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    deploy:
      resources:
        limits:
          cpus: ${DNSMASQ_CPU_LIMIT:-0.5}
          memory: ${DNSMASQ_MEMORY_LIMIT:-128M}
        reservations:
          cpus: ${DNSMASQ_CPU_RESERVATION:-0.1}
          memory: ${DNSMASQ_MEMORY_RESERVATION:-32M}
