version: '3'
services:

  kxs-mysql:
    build:
      context: ./db
    environment:
      MYSQL_ROOT_HOST: "%"
      MYSQL_ROOT_PASSWORD: root
    restart: always
    container_name: kxs-mysql
    image: kxs-mysql
    ports:
      - 3306:3306
    volumes:
      - ./data/mysql/conf/my.cnf:/etc/my.cnf
      - ./data/mysql/logs:/logs
      - ./data/mysql/data:/var/lib/mysql
    networks:
      - kxs_cloud_network

  kxs-register:
    image: nacos/nacos-server:v2.2.3-slim #mac arm架构 单独版本 x86架构下去除-slim
    container_name: kxs-register
    environment:
      # 容器名称使用hostname,否则使用ip，默认ip
      - PREFER_HOST_MODE=hostname
      # 单机模式
      - MODE=standalone
      # 数据源平台 支持mysql或不保存empty
      - SPRING_DATASOURCE_PLATFORM=mysql
      # mysql配置，容器名称
      - MYSQL_SERVICE_HOST=kxs-mysql
      - MYSQL_SERVICE_PORT=3306
      - MYSQL_SERVICE_USER=root
      - MYSQL_SERVICE_PASSWORD=root
      - MYSQL_SERVICE_DB_NAME=kxs_config
      - MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
      # 开启鉴权
      - NACOS_AUTH_ENABLE=true
      - NACOS_AUTH_IDENTITY_KEY=2222
      - NACOS_AUTH_IDENTITY_VALUE=2xxx
      - NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
    volumes:
      - ./logs/nacos:/home/nacos/logs
    ports:
      - "8848:8848"
      - "9848:9848"
    restart: always
    depends_on:
      kxs-mysql:
        condition: service_healthy
    networks:
      - kxs_cloud_network

  kxs-redis:
    image: redis:7.0.6
    ports:
      - 6379:6379
    restart: always
    container_name: kxs-redis
    hostname: kxs-redis
    networks:
      - kxs_cloud_network

#  kxs-gateway:
#    build:
#      context: ./kxs-gateway
#    restart: always
#    ports:
#      - 9999:9999
#    container_name: kxs-gateway
#    hostname: kxs-gateway
#    image: kxs-gateway
#    networks:
#      - kxs_cloud_network
#
#  kxs-system:
#    build:
#      context: ./kxs-system/kxs-system-biz
#    restart: always
#    container_name: kxs-system
#    hostname: kxs-system
#    image: kxs-system
#    volumes:
#      - ./logs/kxs-system-biz:/kxs-system-biz/logs
#    networks:
#      - kxs_cloud_network
#
#  kxs-codegen:
#    build:
#      context: ./kxs-codegen
#    restart: always
#    container_name: kxs-codegen
#    hostname: kxs-codegen
#    image: kxs-codegen
#    volumes:
#      - ./logs/kxs-codegen:/kxs-codegen/logs
#    networks:
#      - kxs_cloud_network
#
#  kxs-quartz:
#    build:
#      context: ./kxs-quartz
#    restart: always
#    image: kxs-quartz
#    container_name: kxs-quartz
#    networks:
#      - kxs_cloud_network
#

#  kxs-mongo:
#    image: mongo:6.0.3
#    ports:
#      - 27017:27017
#    restart: always
#    container_name: kxs-mongo
#    hostname: kxs-mongo
#    environment:
#      TZ: Asia/Shanghai
#      MONGO_INITDB_ROOT_USERNAME: root
#      MONGO_INITDB_ROOT_PASSWORD: root
#    command: mongod --auth
#    volumes:
#      # 数据目录  挂载出来后，即使删除容器，再用该挂载数据与docker-compose.yml文件启动容器，即可恢复到原来的数据以及用户信息
#      - ./data/mongodb/db:/data/db
#      - ./data/mongodb/log:/var/log/mongodb
#      - ./data/mongodb/config:/etc/mongo
#    networks:
#      - kxs_cloud_network

  kxs-seata:
    restart: always
    container_name: kxs-seata
    image: seataio/seata-server:1.8.0
    depends_on:
      - kxs-mysql
    ports:
      - "7091:7091"
      - "8091:8091"
    environment:
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      STORE_MODE: db
      # 以SEATA_IP作为host注册seata server
      SEATA_IP: kxs-seata
      SEATA_PORT: 8091
      JMX_OPTS: -Xmx256m -Xms256m
    volumes:
      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"        #设置系统时区
      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"  #设置时区
      - "./kxs-visual/kxs-seataServer/resources/application.yml:/seata-server/resources/application.yml"
    networks:
      - kxs_cloud_network

  kxs-rabbitmq:
    image: rabbitmq:3.12.8
    container_name: kxs-rabbitmq
    restart: always
    volumes:
      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime"        #设置系统时区
      - "/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"  #设置时区
    ports:
      - 5672:5672
      - 15672:15672
    environment:
      - RABBITMQ_DEFAULT_USER=admin
      - RABBITMQ_DEFAULT_PASS=admin
    networks:
      - kxs_cloud_network

#  kxs-rocket:
#    image: apache/rocketmq:5.1.4
#    hostname: kxs-rocket
#    container_name: kxs-rocket
#    ports:
#      - 9876:9876
#    volumes:
#      - ./logs/rocket:/home/rocketmq/logs
#    command: sh mqnamesrv
#    restart: on-failure
#    networks:
#      - kxs_cloud_network
#
#  kxs-rocket-broker:
#    image: apache/rocketmq:5.1.4
#    hostname: kxs-rocket-broker
#    container_name: kxs-rocket-broker
#    ports:
#      - 10909:10909
#      - 10911:10911
#      - 10912:10912
#    environment:
#      JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
#    volumes:
#      - ./data/broker/store:/home/rocketmq/store
#      - ./kxs-visual/kxs-rocket/broker/broker.conf:/home/rocketmq/conf/broker.conf
#    command: sh mqbroker -n kxs-rocket:9876 -c /home/rocketmq/conf/broker.conf
#    restart: on-failure
#    networks:
#      - kxs_cloud_network
#    depends_on:
#      - kxs-rocket
#
#  kxs-rocket-dashboard:
#    image: apacherocketmq/rocketmq-dashboard:1.0.0
#    container_name: kxs-rocket-dashboard
#    hostname: kxs-rocket-dashboard
#    ports:
#      - 9870:8080
#    environment:
#      - JAVA_OPTS=-Drocketmq.namesrv.addr=kxs-rocket:9876
#    restart: on-failure
#    depends_on:
#      - kxs-rocket-broker
#    networks:
#      - kxs_cloud_network


networks:
  kxs_cloud_network:
    name: kxs_cloud_network
