Unifi Network Application

---
services:
  unifi-db:
    container_name: unifi-db
    image: docker.io/mongo:3.6
    configs:
      - source: init-mongo.js
        target: /docker-entrypoint-initdb.d/init-mongo.js
    environment:
      - PGID=1000
      - PUID=1000
      - TZ=America/New_York
    ports:
      - 27017:27017/tcp
    restart: unless-stopped
    volumes:
      - /var/lib/unifi/unifi-db:/data/db
    networks:
     - unifi-bridge

  unifi-network-application:
    container_name: unifi-network-application
    depends_on:
      - unifi-db
    environment:
      - MONGO_DBNAME=unifi-db
      - MONGO_HOST=unifi-db
      - MONGO_PASS=<generated password>
      - MONGO_PORT=27017
      - MONGO_USER=unifi
      - PGID=1000
      - PUID=1000
      - TZ=America/New_York
    image: lscr.io/linuxserver/unifi-network-application:latest
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 1900:1900/udp #optional
      - 8843:8843 #optional
      - 8880:8880 #optional
      - 6789:6789 #optional
      - 5514:5514/udp #optional
    restart: unless-stopped
    volumes:
      - /var/lib/unifi/config:/config
    networks:
     - unifi-bridge
    privileged: false

networks:
  unifi-bridge:
    driver: bridge

configs:
  init-mongo.js:
    content: |
      db.getSiblingDB("unifi-db").createUser({user: "unifi", pwd: "e<generated password>", roles: [{role: "dbOwner", db: "unifi-db"}]}); 
      db.getSiblingDB("unifi-db_stat").createUser({user: "unifi", pwd: "<generated password>", roles: [{role: "dbOwner", db: "unifi-db_stat"}]});