# 对外仅暴露 443（HTTPS）；内部 api/web/admin 不映射宿主机端口
# version 已废弃，已移除

services:
  api:
    build:
      context: .
      dockerfile: server/Dockerfile
      args:
        GOPROXY: ${GOPROXY:-https://goproxy.cn,direct}
        REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
    image: yh_web-api:latest
    container_name: yh_api
    environment:
      # PORT=8088 仅容器内监听，不映射到宿主机（无 ports 配置）
      - PORT=8088
      - MONGODB_URI=${MONGODB_URI:-mongodb://mongo:27017}
      - MONGODB_DB=${MONGODB_DB:-yxd-agent-testing}
      - GIN_MODE=release
      - ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-https://yuheng.yuxindazhineng.com}
    depends_on:
      - mongo
    networks:
      - yh_net
    # 不暴露宿主机端口，仅由 nginx 容器反代

  web:
    build:
      context: ./web
      dockerfile: Dockerfile
      args:
        REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
    image: yh_web-web:latest
    container_name: yh_web
    volumes:
      # 仅挂载验证文件目录，便于热更新；前台静态站点仍由镜像内 dist 提供
      - ./verify-root:/verify-root:ro
    networks:
      - yh_net
    # 不暴露宿主机端口，仅由 nginx 容器反代

  admin:
    build:
      context: ./admin
      dockerfile: Dockerfile
      args:
        REGISTRY_MIRROR: ${REGISTRY_MIRROR:-}
    image: yh_web-admin:latest
    container_name: yh_admin
    networks:
      - yh_net
    # 不暴露宿主机端口，仅由 nginx 容器反代

  nginx:
    image: ${REGISTRY_MIRROR:-docker.m.daocloud.io/library/}nginx:alpine
    container_name: yh_nginx
    ports:
      - "443:443"
    volumes:
      - ./nginx/yuheng.docker.conf:/etc/nginx/conf.d/default.conf:ro
      - /etc/ssl/yh_web/yuheng.yuxindazhineng.com:/etc/ssl/yh_web/yuheng.yuxindazhineng.com:ro
    depends_on:
      - api
      - web
      - admin
    networks:
      - yh_net

  mongo:
    # 国内默认走镜像；海外可 export REGISTRY_MIRROR= 后直连
    image: ${REGISTRY_MIRROR:-docker.m.daocloud.io/library/}mongo:7
    container_name: yh_mongo
    volumes:
      - mongo_data:/data/db
    networks:
      - yh_net
    # 仅内网，不暴露端口（API 容器内用 mongo:27017）
    # ports:
    #   - "27017:27017"

networks:
  yh_net:
    driver: bridge

volumes:
  mongo_data:
