services:
  dj-multictrl-ntp:
    image: ntp:v1
    container_name: dj-multictrl-ntp
    restart: always
    privileged: true
    ports:
      - "61627:123/udp"
    volumes:
      - /root/dj_multictrl_data/ntp/ntp.conf:/etc/ntp.conf
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-nginx:
    image: nginx:v1
    container_name: dj-multictrl-nginx
    restart: always
    privileged: true
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - '61620:80'
      - '61621:443'
    volumes:
      - /root/dj_multictrl_data/nginx/nginx.conf:/etc/nginx/nginx.conf
      - /root/dj_multictrl_data/nginx/conf.d:/etc/nginx/conf.d
      - /root/dj_multictrl_data/nginx/cert:/etc/nginx/cert
      - /root/dj_multictrl_data/nginx/html:/usr/share/nginx/html
      - /data/dj_multictrl_data/minio/data:/data
      - /data/dj_multictrl_data/live_record:/data/live_record
      - /data/dj_multictrl_data/geoserver:/data/geoserver
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-pgsql:
    image: postgis/postgis:16-3.4
    container_name: dj-multictrl-pgsql
    restart: always
    privileged: true
    environment:
      POSTGRES_DB: dj_multictrl
      POSTGRES_USER: "aros"
      POSTGRES_PASSWORD: "Aros2023"
    ports:
      - "61623:5432"
    volumes:
      - /root/dj_multictrl_data/pgsql/data:/var/lib/postgresql/data
      - /root/dj_multictrl_data/pgsql/initdb.d:/docker-entrypoint-initdb.d/
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-minio:
    image: minio/minio:RELEASE.2021-11-05T09-16-26Z
    container_name: dj-multictrl-minio
    restart: always
    privileged: true
    ports:
      - '61624:9000'
      - '61625:9001'
    volumes:
      - /data/dj_multictrl_data/minio/data:/data
      - /data/dj_multictrl_data/minio/config:/root/.minio
      - /etc/localtime:/etc/localtime:ro
    environment:
      MINIO_ACCESS_KEY: aros
      MINIO_SECRET_KEY: Aros2023
    command: server /data --console-address ":9001" -address ":9000"

  dj-multictrl-emqx:
    image: emqx/emqx:5.8.0
    container_name: dj-multictrl-emqx
    restart: always
    privileged: true
    ports:
      - '61626:18083'
      - '61627:1883'
      - '61628:8083'
    environment:
      - TZ=Asia/Shanghai
      # 关键变量 1: 固定节点名，避免因容器IP变化导致数据失效
      - EMQX_NODE_NAME=emqx@dj-multictrl-emqx
      # 关键变量 2: 正确设置 Dashboard 密码 (针对 5.x 版本)
      - EMQX_DASHBOARD__DEFAULT_PASSWORD=Multictrl2023
      #- EMQX_ADMIN_PASSWORD=2023
    volumes:
      - /root/dj_multictrl_data/emqx/logs:/opt/emqx/log
      - /root/dj_multictrl_data/emqx/data:/opt/emqx/data
      - /root/dj_multictrl_data/emqx/etc/emqx.conf:/opt/emqx/etc/emqx.conf
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-emqx2:
    image: emqx/emqx:5.8.0
    container_name: dj-multictrl-emqx2
    restart: always
    privileged: true
    ports:
      - '61636:18083'
      - '61637:1883'
      - '61638:8083'
    environment:
      - TZ=Asia/Shanghai
      - EMQX_NODE_NAME=emqx@dj-multictrl-emqx2
      - EMQX_DASHBOARD__DEFAULT_PASSWORD=Multictrl2023
    volumes:
      - /root/dj_multictrl_data/emqx2/logs:/opt/emqx/log
      - /root/dj_multictrl_data/emqx2/data:/opt/emqx/data
      - /root/dj_multictrl_data/emqx2/etc/emqx.conf:/opt/emqx/etc/emqx.conf
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-srs:
    image: ossrs/srs:5
    container_name: dj-multictrl-srs
    restart: always
    privileged: true
    environment:
      - TZ=Asia/Shanghai
      - CANDIDATE=${HOST_IP}
    ports:
      - '61629:61629'
      - '61630:61630'
      - '61631:61631'
      - '61632:61632/udp'
      - '61632:61632'
    volumes:
      - /root/dj_multictrl_data/srs/conf/docker.conf:/usr/local/srs/conf/docker.conf
      - /data/dj_multictrl_data/live_record:/live_record
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-influxdb:
    image: influxdb:2.7
    container_name: dj-multictrl-influxdb
    restart: always
    privileged: true
    ports:
      - "61634:8086"
    environment:
      DOCKER_INFLUXDB_INIT_MODE: "setup"
      DOCKER_INFLUXDB_INIT_USERNAME: "aros" #创建管理员用户
      DOCKER_INFLUXDB_INIT_PASSWORD: "Aros2023" #创建管理员密码，太简单会报错
      DOCKER_INFLUXDB_INIT_ORG: "dj" #组织名称
      DOCKER_INFLUXDB_INIT_BUCKET: "flight_records"
      DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: "u32ol28aVjyZzAi1Wi-GydHcULZymvqZMKOX8lLZUwr3WdTpx1rBB2sBvk62_0zo7Ot0LnsgxJlHA0gInegWXg=="
      DOCKER_INFLUXDB_INIT_RETENTION: "54w"
    volumes:
      - /root/dj_multictrl_data/influxdb/data:/var/lib/influxdb2
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-mongodb:
    image: mongo:latest
    container_name: dj-multictrl-mongodb
    restart: always
    privileged: true
    ports:
      - "61639:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: aros
      MONGO_INITDB_ROOT_PASSWORD: Aros2023
      MONGO_INITDB_DATABASE: dj_multictrl
    volumes:
      - /root/dj_multictrl_data/mongodb/data:/data/db
      - /etc/localtime:/etc/localtime:ro

  dj-multictrl-api:
    image: openjdk:17
    container_name: dj-multictrl-api
    restart: always
    privileged: true
    ports:
      - '61635:8080'
    volumes:
      - /root/dj_multictrl_data/wait/wait-for-it.sh:/wait-for-it.sh
      - /root/dj_multictrl_data/api/dj-multictrl-admin.jar:/dj-multictrl-admin.jar
      - /root/dj_multictrl_data/api/config/application.yml:/config/application.yml
      - /root/dj_multictrl_data/api/config/application-docker.yml:/config/application-docker.yml
      - /root/dj_multictrl_data/api/temp:/temp
      - /root/dj_multictrl_data/api/logs:/logs
      - /data/dj_multictrl_data/live_record:/live_record
      - /root/dj_multictrl_data/ffmpeg/ffmpeg:/usr/bin/ffmpeg
      - /data/dj_multictrl_data/minio/data:/minio_data
      - /etc/localtime:/etc/localtime:ro
      - /root/dj_multictrl_data/api/tmp:/tmp
    command:
      - /bin/bash
      - -c
      - |
        ./wait-for-it.sh dj-multictrl-pgsql:5432 -t 0 -- java  -jar -Dhost.is-ssl=${USE_HTTPS} -Dminio.other.dataPath=/minio_data -Duser.timezone=Asia/Shanghai -Dhost.ip=${HOST_IP} -Dhost.port=${HOST_PORT} -Dintranet.ip=${DEPLOY_INTERNAL_IP} -Ddeploy.network.loopBack=${DEPLOY_NETWORK_LOOP_BACK} dj-multictrl-admin.jar