services:
  wg-easy:
    image: ghcr.io/wg-easy/wg-easy:latest
    container_name: wg-easy
    restart: unless-stopped
    # env_file values still go through compose interpolation, so every `$` in the
    # bcrypt hash has to be written as `$$` in .env. This cost three rebuilds.
    env_file:
      - .env
    environment:
      - WG_PORT=51820
      # Plain HTTP for the admin UI. Safe only because the port is bound to loopback
      # below; drop this line the moment TLS goes in front of it.
      - INSECURE=true
    volumes:
      - etc_wireguard:/etc/wireguard
    ports:
      # the tunnel
      - "51820:51820/udp"
      # the admin UI: 127.0.0.1 only, so it never appears on the LAN
      - "127.0.0.1:51821:51821/tcp"
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1

volumes:
  etc_wireguard:
