# Copyright (c) 2023 Navigio UG (haftungsbeschränkt)
# This software is provided 'as-is', without any express or implied warranty. 
# In no event will the authors be held liable for any damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose, including 
# commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; 
#    you must not claim that you wrote the original software. 
#    If you use this software in a product, an acknowledgment in the product 
#    documentation would be appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented as 
#    being the original software.
# 3. This notice may not be removed or altered from any source distribution.
---
version: "3"
services:
  unifi-db:
    # Synology models later than x20:
    # image: docker.io/mongo:7
    # Synology models with Celeron and Atom CPUs:
    image: docker.io/mongo:4.4
    container_name: unifi-db
    volumes:
      - /var/lib/docker/volumes/unifi-nwa/data:/data/db
      - /var/lib/docker/volumes/unifi-nwa/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    healthcheck:
      # mongodb >= 6.0
      # test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      # mongodb < 6.0
      test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 20s
    restart: unless-stopped
    networks:
      default:
        ipv4_address: 192.168.2.155

  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-network-application
    environment:
      - PUID=0
      - PGID=0
      - TZ=Etc/UTC
      - MONGO_USER=unifi
      - MONGO_PASS=#DgZh5Abs1!#
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi
      - MEM_LIMIT=1024 #optional
      - MEM_STARTUP=1024 #optional
    #  - MONGO_TLS= #optional
    #  - MONGO_AUTHSOURCE= #optional
    depends_on:
      unifi-db:
        condition: service_healthy
    volumes:
      - /var/lib/docker/volumes/unifi-nwa/config:/config
    #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
    networks:
      default:
        ipv4_address: 192.168.2.156

networks:
  default:
    name: unifi-nwa
    external: true