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


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


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


services:
  wlc:
    image: jacobalberty/unifi:{{ app.versions.wlc }}
    hostname: en1-unifi-wlc
    init: true
    networks:
      - unifi
    ports:
      - published: {{ app.ports.8080 }}
        target: 8080
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.8443 }}
        target: 8443
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.8843 }}
        target: 8843
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.8880 }}
        target: 8880
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.3478 }}
        target: 3478
        protocol: udp
        mode: ingress
      - published: {{ app.ports.6789 }}
        target: 6789
        protocol: tcp
        mode: ingress
      - published: {{ app.ports.10001 }}
        target: 10001
        protocol: udp
        mode: ingress
    volumes:
      - type: volume
        source: unifi-data
        target: /unifi
        read_only: false
    environment:
      RUNAS_UID0: "false"
      UNIFI_UID: "{{ _app_account.uid }}"
      UNIFI_GID: "{{ _app_account.uid }}"
      TZ: "Americas/New_York"
    deploy:
      replicas: 1
