---
version: "{{ skylab_compose_version }}"

networks:
  adguard:
    name: adguard
    driver: overlay
    ipam:
      driver: default
      config:
        - subnet: "{{ app.networks.ext }}"

volumes:
{% for key, value in app.volumes.items() %}
  adguard-{{ key }}:
    name: datastore{{ value }}
    driver: glusterfs
{% endfor %}

services:
  server:
    image: adguard/adguardhome:{{ app.versions.server }}
    hostname: adguard
    networks:
      - adguard
    dns:
{% for server in app.settings.upstream %}
      - {{ server }}
{% endfor %}
    ports:
      - published: {{ app.ports.53 }}
        target: 53
        protocol: udp
        mode: ingress
      - published: {{ app.ports.53 }}
        target: 53
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.8064 }}
        target: 8064
        protocol: tcp
        mode: ingress
    volumes:
      - type: volume
        source: adguard-config
        target: /opt/adguardhome/conf
        read_only: false
      - type: volume
        source: adguard-data
        target: /opt/adguardhome/work
        read_only: false
    deploy:
      replicas: 1
