version: '3.8'

services:
  mysql:
    image: mysql:8
    container_name: mysql
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: qihang_erp
      MYSQL_USER: qihang_erp
      MYSQL_PASSWORD: qihang_erp@123
    ports:
      - "3306:3306"
    volumes:
      - /opt/qihangerp-open/mysql_data:/var/lib/mysql
      - ./my.cnf:/etc/mysql/conf.d/my.cnf
    restart: always
    networks:
      - my-network


  redis:
    image: redis:7
    container_name: redis
    ports:
      - "6379:6379"  # 映射6379端口
    command: ["redis-server"]  # 允许所有IP访问
    volumes:
      - redis_data:/data
    restart: always
    networks:
      - my-network

  nacos:
    image: nacos/nacos-server:v2.3.2
    container_name: nacos
    environment:
      MODE: standalone  # 单机模式
      NACOS_AUTH_ENABLED: "false"  # 禁用认证
    ports:
      - "8848:8848"
      - "9848:9848"
    restart: always
    volumes:
      - nacos_data:/home/nacos/data
    networks:
      - my-network  # 自定义网络
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8848/nacos/v1/ns/operator/servers"]
      interval: 10s
      retries: 5
      start_period: 20s
      timeout: 5s

  gateway:
    image: crpi-km68smz26eegv27m.cn-shenzhen.personal.cr.aliyuncs.com/qihang-open/gateway:v251229
    container_name: qihangerp-gateway
    environment:
      SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: "nacos"
    ports:
      - "8088:8088"
    depends_on:
      - redis
      - nacos
    restart: always
    networks:
      - my-network

  sys-api:
    image: crpi-km68smz26eegv27m.cn-shenzhen.personal.cr.aliyuncs.com/qihang-open/sys-api:v251229
    container_name: qihangerp-sys-api
    environment:
      SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_CONFIG_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_PASSWORD: "nacos"
      spring.data.redis.host: "redis"
      spring.data.redis.port: 6379
      spring.data.redis.password: ""
      SPRING_DATASOURCE_URL: "jdbc:mysql://mysql:3306/qihang_erp?useSSL=false&serverTimezone=UTC"
      SPRING_DATASOURCE_USERNAME: "qihang_erp"
      SPRING_DATASOURCE_PASSWORD: "qihang_erp@123"
      spring.profiles.active: dev
    depends_on:
      - redis
      - nacos
    restart: always
    networks:
      - my-network

  oms-api:
    image: crpi-km68smz26eegv27m.cn-shenzhen.personal.cr.aliyuncs.com/qihang-open/oms-api:v251229
    container_name: qihangerp-oms-api
    environment:
      SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_CONFIG_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_PASSWORD: "nacos"
      spring.data.redis.host: "redis"
      spring.data.redis.port: 6379
      spring.data.redis.password: ""
      SPRING_DATASOURCE_URL: "jdbc:mysql://mysql:3306/qihang_erp?useSSL=false&serverTimezone=UTC"
      SPRING_DATASOURCE_USERNAME: "qihang_erp"
      SPRING_DATASOURCE_PASSWORD: "qihang_erp@123"
      spring.profiles.active: dev
    depends_on:
      - redis
      - nacos
    restart: always
    networks:
      - my-network

  erp-api:
    image: crpi-km68smz26eegv27m.cn-shenzhen.personal.cr.aliyuncs.com/qihang-open/erp-api:v251229
    container_name: qihangerp-erp-api
    environment:
      SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_SERVER-ADDR: "nacos:8848"
      SPRING_CLOUD_NACOS_CONFIG_USERNAME: "nacos"
      SPRING_CLOUD_NACOS_CONFIG_PASSWORD: "nacos"
      spring.data.redis.host: "redis"
      spring.data.redis.port: 6379
      spring.data.redis.password: ""
      SPRING_DATASOURCE_URL: "jdbc:mysql://mysql:3306/qihang_erp?useSSL=false&serverTimezone=UTC"
      SPRING_DATASOURCE_USERNAME: "qihang_erp"
      SPRING_DATASOURCE_PASSWORD: "qihang_erp@123"
      spring.profiles.active: dev
    depends_on:
      - redis
      - nacos
    restart: always
    networks:
      - my-network

  vue:
    image: crpi-km68smz26eegv27m.cn-shenzhen.personal.cr.aliyuncs.com/qihang-open/vue-erp:v251229a
    container_name: qihangerp-vue
    ports:
      - "88:88"  # 映射88端口
#    volumes:
#      - /opt/qihangerp/nginx/dist:/usr/share/nginx/html  # HTML 文件目录
#      - /opt/qihangerp/nginx/nginx_conf/nginx:/etc/nginx  # Nginx 配置目录
#      - /opt/qihangerp/nginx/nginx_logs:/var/log/nginx  # Nginx 日志目录
    networks:
      - my-network  # 使用 my-network 网络
    restart: always  # 容器崩溃后自动重启


volumes:
  redis_data:  # 定义持久化数据卷
  nacos_data:
networks:
  my-network:
    driver: bridge