services:
  ddns:
    image: qmcgaw/ddns-updater
    container_name: ddns-updater
    restart: unless-stopped
    environment:
      TZ: America/Edmonton
      PERIOD: 5m
      PUBLICIP_FETCHERS: http
      PUBLICIP_HTTP_PROVIDERS: all
      # Using the pipe (|) allows multi-line JSON safely
      CONFIG: |
        {
          "settings": [
            {
              "provider": "desec",
              "domain": "mapletree.email",
              "host": "@",
              "token": "${DESEC_TOKEN}",
              "ip_version": "ipv4"
            },
            {
              "provider": "desec",
              "domain": "mapletree.email",
              "host": "*",
              "token": "${DESEC_TOKEN}",
              "ip_version": "ipv4"
            }
          ]
        }
    volumes:
      # Gluster Path for HA
      - /shared/ddns:/updater/data
    networks:
      - ddns_external      # Talk to Traefik
    labels:
      - "traefik.enable=${DDNS_TRAEFIK_ENABLED}"
      # TRAEFIK MUST BE ON THIS NETWORK:
      - "traefik.docker.network=ddns_external"
      
      # Router
      - "traefik.http.routers.ddns.rule=Host(`${DDNS_ROOT_NAME}.${TRAEFIK_ROOT_SUFFIX}`)"
      - "traefik.http.routers.ddns.entrypoints=websecure"
      - "traefik.http.routers.ddns.tls=true"
      - "traefik.http.routers.ddns.tls.certresolver=dns_resolver"
      # Service
      - "traefik.http.services.ddns.loadbalancer.server.port=8000"

networks:
  ddns_external:
    driver: bridge