version: "3.9"  # optional since v1.27.0
services:    
  obpm-designer:
    build:
      context: .
      dockerfile: Dockerfile.designer
    environment:
      spring.cloud.consul.host: consul-srv
    networks:
      mynet:
        aliases:
         - obpm-designer-srv
    ports:
      - "8082:8082"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul
      
  obpm-gateway:
    build:
      context: .
      dockerfile: Dockerfile.gateway
    environment:
      spring.cloud.consul.host: consul-srv
    networks:
      mynet:
        aliases:
         - obpm-gateway-srv
    ports:
      - "8080:8080"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul

  obpm-signon:
    build:
      context: .
      dockerfile: Dockerfile.signon
    environment:
      spring.cloud.consul.host: consul-srv
      spring.datasource.url: jdbc:mysql://mysql-srv:3307/obpm2?characterEncoding=UTF-8&serverTimezone=GMT
      spring.datasource.password: 
      spring.redis.host: redis-srv
    networks:
      mynet:
        aliases:
         - obpm-signon-srv
#    ports:
#      - "8010:8010"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul

  obpm-message:
    build:
      context: .
      dockerfile: Dockerfile.message
    environment:
      spring.cloud.consul.host: consul-srv
      spring.datasource.url: jdbc:mysql://mysql-srv:3307/message?characterEncoding=UTF-8&serverTimezone=GMT
      spring.datasource.password: 
      spring.redis.host: redis-srv
    networks:
      mynet:
        aliases:
         - obpm-message-srv
#    ports:
#      - "8084:8084"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul
      
  obpm-email:
    build:
      context: .
      dockerfile: Dockerfile.email
    environment:
      spring.cloud.consul.host: consul-srv
      spring.datasource.url: jdbc:mysql://mysql-srv:3307/email?characterEncoding=UTF-8&serverTimezone=GMT
      spring.datasource.password: 
      spring.redis.host: redis-srv
    networks:
      mynet:
        aliases:
         - obpm-email-srv
#    ports:
#      - "8086:8086"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul

  obpm-runtime:
    build:
      context: .
      dockerfile: Dockerfile.runtime
    environment:
      spring.cloud.consul.host: consul-srv
      spring.datasource.url: jdbc:mysql://mysql-srv:3307/obpm2?characterEncoding=UTF-8&serverTimezone=GMT
      spring.datasource.password: 
      spring.redis.host: redis-srv
      JAVA_FONTS: /storage/fonts
    networks:
      mynet:
        aliases:
         - obpm-runtime-srv
#    ports:
#      - "8083:8083"
    volumes:
      - ./storage:/storage
      - ./storage/fonts:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/fonts/fallback
    links:
      - redis
      - mysql
      - consul
      
  obpm-kms:
    build:
      context: .
      dockerfile: Dockerfile.kms
    environment:
      spring.cloud.consul.host: consul-srv
      spring.datasource.url: jdbc:mysql://mysql-srv:3307/kms?characterEncoding=UTF-8&serverTimezone=GMT
      spring.datasource.password: 
      spring.redis.host: redis-srv
    networks:
      mynet:
        aliases:
         - obpm-kms-srv
#    ports:
#      - "8888:8888"
    volumes:
      - ./storage:/storage
    links:
      - redis
      - mysql
      - consul

  consul: # 服务名称，用户自定义
    image: consul:1.4.3  # 镜像版本
#    network_mode: "host"
    container_name: consul_node1
    networks:
      mynet:
        aliases:
         - consul-srv
    command:  agent -server -bootstrap-expect 1 -bind=0.0.0.0 -ui -client=0.0.0.0
    ports:
    - 8400:8400  # 暴露端口
    - 8500:8500
    volumes: # 挂载
    - ./static:/usr/share/nginx/html
    privileged: true # 这个必须要，解决nginx的文件调用的权限问题

  mysql:
    networks:
      mynet:
        aliases:
         - mysql-srv
    ports:
      - "3307:3307"
    restart: always
    environment:
      TZ: Asia/Shanghai
#      MYSQL_ROOT_PASSWORD: ""
      MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
      MYSQL_USER: 'test'
      MYSQL_PASS: 'test'
    image: "mysql:5.7" 
    container_name: mysql
    volumes:
      - "./mysql/data:/var/lib/mysql"
      - "./mysql/my.cnf:/etc/my.cnf"
      - "./mysql/init:/docker-entrypoint-initdb.d"
  nginx: # 服务名称，用户自定义
    image: nginx:latest  # 镜像版本
    networks:
      mynet:
        aliases:
         - nginx-srv
    ports:
    - 80:80  # 暴露端口
    volumes: # 挂载
    - ./nginx/html:/usr/share/nginx/html
    - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
    privileged: true # 这个必须要，解决nginx的文件调用的权限问题
    links:
      - obpm-gateway
  redis:
    image: redis
    container_name: my_redis
    networks:
      mynet:
        aliases:
         - redis-srv
    ports:
      - "6379:6379"
    volumes:
      - ./redis/data:/data
volumes:
  storage: {}
networks:
  mynet:
    driver: bridge