version: '3.8'

# 网络
networks:
  default:
    name: default-network
    external: true

services:
  #nginx反向代理
  cr-nginx:
    image: "registry.cn-chengdu.aliyuncs.com/infish/pack-comm-nginx:1.23.1"
    restart: always
    ports:
      - 8085:80
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/www:/usr/share/nginx/html
      # - ./nginx/www:/root/www/html

    depends_on:
      - cr-svc
      - cr-user
      
  #bus消息中间件
  cr-bus:
    restart: always
    image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-bus:v1.0.0
    volumes:
      - ./config-service.yaml:/root/bus/app.yaml

    depends_on:
      - cr-mongo
      - cr-redis
    ports:
      - 14222:4222

  #redis缓存
  cr-redis:
    image: "redis:alpine"
    restart: always
    command:
      --requirepass "crzzz_x" #这一行是设置密码
    privileged: true
    ports:
      - 16379:6379

  cr-mongo:
    image: mongo:4.4.1
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: crzzz_x
    volumes:
      - ~/cr-svc/data/mongo/db:/data/db
      - ~/cr-svc/data/mongo/log:/var/log/mongodb
    ports: 
      - 17017:27017

  # cr-user:
  #   image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-usercenter:v1.0.1
  #   restart: always
  #   depends_on:
  #     - cr-bus
  #   environment: 
  #     NATS: nats://cr-bus:4222
  #     CONFIGER_MONGO: cr-user-mongo
  #     CONFIGER_REDIS: cr-redis
  #     CONFIGER_JWT: crsvc#crsvc_zzzzxxx#168
  #     IGNORE_USERTYPE: "true"
  #     # MONGO_MIGRATIONS: /data/migrations==mongodb://root:3dshow@3dshow-mongo-alpha:27017/supply-user?authSource=admin&&/data/migrations==mongodb://user:password@host:port/dbname?query
  #     MONGO_MIGRATIONS: /data/migrations==mongodb://root:crzzz_x@cr-mongo:27017/user?authSource=admin
  #   volumes:
  #     - ./mongo-migrations:/data/migrations

  cr-svc:
    image: registry.cn-chengdu.aliyuncs.com/infish/pack-cr:v1.0.0
    restart: always
    depends_on:
      - cr-bus
    volumes:
    # api上传:配置文件上传地址package对应/cr/pkg
    # dockerfile中添加package目录到容器/root/projects/package
    # 上传文件挂载到宿主机本地目录
      - ~/cr-svc/data/package:/root/projects/package
      # 部署时,调用start.sh,获取宿主机ip注入api容器中
      - ./url:/root/projects/url
    environment: 
      NATS: nats://cr-bus:4222
