services:

########## 数据库 ##########
  mysql:
    container_name: mysql
    image: mysql:8.4.5
    environment:
      MYSQL_ROOT_PASSWORD: aegis
      MYSQL_ROOT_HOST: '%'
    volumes:
      - mysql_data:/var/lib/mysql
      - ./mysql:/docker-entrypoint-initdb.d
    networks:
      - aegis_network
    command:
      - --lower_case_table_names=1
      - --max_connections=1000
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 30s
      timeout: 10s
      retries: 10
    restart: always

  adminer:
    container_name: adminer
    image: adminer:5.3.0-standalone
    networks:
      - aegis_network
    restart: always
    depends_on:
      mysql:
        condition: service_healthy

########## 缓存 ##########
  redis:
    container_name: redis
    image: redis:8.0.2-bookworm
    networks:
      - aegis_network
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 30s
      retries: 50
      start_period: 30s
    restart: always

  redisinsight:
    container_name: redisinsight
    image: redis/redisinsight:2.70
    environment:
      RI_APP_HOST: redis
      RI_APP_PORT: 6379
    networks:
      - aegis_network
    restart: always
    depends_on:
      redis:
        condition: service_healthy

########## 视频监控 ##########
  zlmediakit:
    container_name: zlmediakit
    image: zlmediakit/zlmediakit:master
    environment:
      - TZ=Asia/Shanghai
    ports:
      - "554:554/tcp"
      - "554:554/udp"
      - "1935:1935/tcp"
      - "30000-30500:30000-30500/udp"
    networks:
      - aegis_network
      - public_network
    restart: always

########## 视频会议 ##########
  prosody:
    container_name: prosody
    image: jitsi/prosody:prosody-13.0.2
    environment:
      - AUTH_TYPE=internal
      - ENABLE_AUTH=0
      - ENABLE_GUESTS=1
      - XMPP_DOMAIN=meet.jitsi
      - XMPP_AUTH_DOMAIN=auth.meet.jitsi
      - XMPP_MUC_DOMAIN=muc.meet.jitsi
      - XMPP_INTERNAL_MUC_DOMAIN=internal-muc.meet.jitsi
      - XMPP_GUEST_DOMAIN=guest.meet.jitsi
      - JVB_BREWERY_MUC=jvbbrewery
      - JVB_PORT=10000
      - JICOFO_AUTH_USER=focus
      - JICOFO_AUTH_PASSWORD=jitsi123
      - JVB_AUTH_USER=jvb
      - JVB_AUTH_PASSWORD=jitsi123
    networks:
      - aegis_network
    restart: always
  jvb:
    container_name: jvb
    image: jitsi/jvb:jvb-2.3-262-gd2dc4df00-1
    environment:
      - ENABLE_AUTH=0
      - XMPP_DOMAIN=meet.jitsi
      - XMPP_AUTH_DOMAIN=auth.meet.jitsi
      - XMPP_INTERNAL_MUC_DOMAIN=internal-muc.meet.jitsi
      - XMPP_SERVER=prosody
      - JVB_BREWERY_MUC=jvbbrewery
      - JVB_PORT=10000
      - JVB_ENABLE_APIS=rest,colibri
      - JVB_AUTH_USER=jvb
      - JVB_AUTH_PASSWORD=jitsi123
    ports:
      - "10000:10000/udp"
      - "10000:10000/tcp"
    volumes:
      - jvb_config:/config
    networks:
      - aegis_network
    restart: always
    depends_on:
      - prosody
  jicofo:
    container_name: jicofo
    image: jitsi/jicofo:jicofo-1.0-1167-1
    environment:
      - ENABLE_AUTH=0
      - XMPP_DOMAIN=meet.jitsi
      - XMPP_AUTH_DOMAIN=auth.meet.jitsi
      - XMPP_INTERNAL_MUC_DOMAIN=internal-muc.meet.jitsi
      - XMPP_SERVER=prosody
      - JVB_BREWERY_MUC=jvbbrewery
      - JVB_PORT=10000
      - JICOFO_AUTH_USER=focus
      - JICOFO_AUTH_PASSWORD=jitsi123
    networks:
      - aegis_network
    restart: always
    depends_on:
      - prosody
      - jvb
  jitsi-web:
    container_name: jitsi-web
    image: jitsi/web:web-1.0.8954-1
    environment:
      - ENABLE_AUTH=0
      - ENABLE_GUESTS=1
      - ENABLE_RECORDING=1
      - PUBLIC_URL=http://localhost:8443
      - XMPP_DOMAIN=meet.jitsi
      - XMPP_AUTH_DOMAIN=auth.meet.jitsi
      - XMPP_MUC_DOMAIN=muc.meet.jitsi
      - XMPP_INTERNAL_MUC_DOMAIN=internal-muc.meet.jitsi
      - XMPP_GUEST_DOMAIN=guest.meet.jitsi
      - XMPP_BOSH_URL_BASE=http://prosody:5280
      - JVB_BREWERY_MUC=jvbbrewery
      - JVB_PORT=10000
      - DEFAULT_LANGUAGE=zh
    ports:
      - "8443:80"
    volumes:
      - jitsi_web_config:/config
    networks:
      - aegis_network
      - public_network
    restart: always
    depends_on:
      - prosody
      - jicofo
      - jvb

########## 反向代理 ##########
  nginx:
    container_name: nginx
    image: nginx:1.29.0-alpine3.22
    volumes:
      - ./nginx/aegis.conf:/etc/nginx/conf.d/aegis.conf
    ports:
      - "3306:3306"
      - "6379:6379"
      - "8080:8080"
    networks:
      - aegis_network
      - public_network
    restart: always
    depends_on:
      aegis-ui:
        condition: service_healthy

########## 应急指挥 ##########
  aegis-admin:
    container_name: aegis-admin
    build:
      context: ../
      dockerfile: ./deployment/Dockerfile
      target: aegis-admin
    environment:
      JVM_XMS: 512
      JVM_XMX: 1024
      SERVER_PORT: 8080
      SPRING_PROFILE: druid
      # ZLMediaKit 配置（通过环境变量覆盖 zlm.* 配置）
      ZLM_BASE_URL: http://zlmediakit:80      # 根据实际 ZLMediaKit HTTP 端口调整
      ZLM_SECRET: ""                          # 填写与 ZLMediaKit 配置中 api.secret 一致的值
      ZLM_APP: live
      ZLM_VHOST: __defaultVhost__
      ZLM_ENABLE_HLS: "true"
      ZLM_ENABLE_MP4: "false"
    volumes:
      - aegis_data:/app/upload
    networks:
      - aegis_network
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: always

  aegis-ui:
    container_name: aegis-ui
    build:
      context: ../
      dockerfile: ./deployment/Dockerfile
      target: aegis-ui
    networks:
      - aegis_network
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:80 || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: always

########## 存储卷 ##########
volumes:
  mysql_data:
  aegis_data:
  jvb_config:
  jitsi_web_config:

########## 存储卷 ##########
networks:
  aegis_network:
    driver: bridge
    internal: true
  public_network:
    driver: bridge
    internal: false