version: '3.5'

services:
### SVC:mysql:>>>
  mysql0:
    hostname: mysql0
    image: 192.168.251.78/edoc2v5/mysql:v8.0.25.1-security
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/mysql:/var/lib/mysql
#      - /home/edoc2/macrowing/edoc2v5/data/dbbackup:/dbbackup
    environment:
#      - DBBACKUP=true
      - MODE=cluster
    labels:
      "type": "2"
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.mysqllabels == mysql0
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  mysql1:
    hostname: mysql1
    image: 192.168.251.78/edoc2v5/mysql:v8.0.25.1-security
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/mysql:/var/lib/mysql
#      - /home/edoc2/macrowing/edoc2v5/data/dbbackup:/dbbackup
    environment:
#      - DBBACKUP=true
      - MODE=cluster
    labels:
      "type": "2"
    networks:
      - middleware
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.mysqllabels == mysql1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  mysql2:
    hostname: mysql2
    image: 192.168.251.78/edoc2v5/mysql:v8.0.25.1-security
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/mysql:/var/lib/mysql
      - /home/edoc2/macrowing/edoc2v5/data/dbbackup:/dbbackup
    environment:
      - DBBACKUP=true
      - TASKS=10 0 * * *
      - DAYS=15
      - MODE=cluster
    labels:
      "type": "2"
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.mysqllabels == mysql2
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
### SVC:mysql:<<<
  redis1:
    hostname: redis1
    image: 192.168.251.78/edoc2v5/redis-huawei:v4.0.14.4-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/redis:/data
    networks:
      - middleware
    environment:
      - ROLE=master
    deploy:
      placement:
        constraints:
          - node.labels.redislabels == redis1
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  redis2:
    hostname: redis2
    image: 192.168.251.78/edoc2v5/redis-huawei:v4.0.14.4-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/redis:/data
    networks:
      - middleware
    environment:
      - ROLE=slave
    deploy:
      placement:
        constraints:
          - node.labels.redislabels == redis2
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  redis3:
    hostname: redis3
    image: 192.168.251.78/edoc2v5/redis-huawei:v4.0.14.4-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/redis:/data
    networks:
      - middleware
    environment:
      - ROLE=slave
    deploy:
      placement:
        constraints:
          - node.labels.redislabels == redis3
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  rabbitmq:
    hostname: rabbitmq
    image: 192.168.251.78/edoc2v5/rabbitmq-huawei:v3.7.17.1-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/rabbitmq:/var/lib/rabbitmq
    networks:
      - middleware
    environment:
      - ROLE=master
    deploy:
      placement:
        constraints:
          - node.labels.rabbitmqlabels == rabbitmq1
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  rabbitmq2:
    hostname: rabbitmq2
    image: 192.168.251.78/edoc2v5/rabbitmq-huawei:v3.7.17.1-20210603
    depends_on:
      - rabbitmq
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/rabbitmq:/var/lib/rabbitmq
    networks:
      - middleware
    environment:
      - ROLE=slave
    deploy:
      placement:
        constraints:
          - node.labels.rabbitmqlabels == rabbitmq2
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  es:
    hostname: es
    image: registry.edoc2.com:5000/edoc2v5/elasticsearch-huawei:v6.7.1.2-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/es:/esdata
    environment:
      - ES_JAVA_OPTS=-Xms8g -Xmx8g
      - NODE_NAME=es-node1
      - MODE=cluster
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.eslabels == es1
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  es2:
    hostname: es2
    image: registry.edoc2.com:5000/edoc2v5/elasticsearch-huawei:v6.7.1.2-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/es:/esdata
    environment:
      - ES_JAVA_OPTS=-Xms8g -Xmx8g
      - NODE_NAME=es-node2
      - MODE=cluster
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.eslabels == es2
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  es3:
    hostname: es3
    image: registry.edoc2.com:5000/edoc2v5/elasticsearch-huawei:v6.7.1.2-20210603
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/es:/esdata
    environment:
      - ES_JAVA_OPTS=-Xms8g -Xmx8g
      - NODE_NAME=es-node3
      - MODE=cluster
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.eslabels == es3
      replicas: 1
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
### SVC:mysql:>>>
  mysql:
    hostname: mysql
    image: 192.168.251.78/edoc2v5/haproxy:v1.8.21.8-security
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    networks:
      - middleware
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:mysql:<<<
  proxy:
    hostname: proxy
    image: 192.168.251.78/edoc2v5/nginx:v1.18.0-huawei-20210521
    command: /etc/nginx/proxy.sh
    environment:
      - MIDDLEWARE=cluster
    ports:
      - "30001:30001"    #mysql
      - "30003:30003"    #es
      - "30004:30004"    #rabbitmq
      - "30005:30005"    #redis
      - "30006:30006"    #haproxy
    deploy:
      replicas: 0
      restart_policy:
        condition: on-failure
    networks:
      - middleware
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
networks:
  middleware:
    external: true
    name: macrowing
