version: '3.5'

services:
  mysql:
    hostname: mysql
    image: registry.edoc2.com:5000/edoc2v5/mysql:v8.0.17.8
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/mysql:/var/lib/mysql
#      - "/home/edoc2/macrowing/edoc2v5/data/dbbackup:/dbbackup"
    environment:
#      - DBBACKUP=true
      - MODE=standalone
    networks:
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.nodelabels == Middleware
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  redis:
    hostname: redis
    image: registry.edoc2.com:5000/edoc2v5/redis:v4.0.14.4
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/redis:/data
    networks: 
      - middleware
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodelabels == Middleware
      endpoint_mode: dnsrr
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  rabbitmq:
    hostname: rabbitmq
    image: registry.edoc2.com:5000/edoc2v5/rabbitmq:v3.7.17.1
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/rabbitmq:/var/lib/rabbitmq
    networks: 
      - middleware
    deploy:
      placement:
        constraints:
          - node.labels.nodelabels == Middleware
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  es:
    image: registry.edoc2.com:5000/edoc2v5/elasticsearch:v6.7.1.2
    hostname: es
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/es:/esdata
    networks: 
      - middleware
    environment:
      - node.name=es
      - ES_JAVA_OPTS=-Xmx8g -Xms8g
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodelabels == Middleware
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"
  proxy: 
    hostname: proxy
    image: registry.edoc2.com:5000/edoc2v5/nginx:1.16.2
    command: /etc/nginx/proxy.sh
    ports:
      - "30001:30001"    #mysql
      - "30003:30003"    #es
      - "30004:30004"    #rabbitmq
      - "30005:30005"    #redis
    deploy:
      replicas: 0
      placement:
        constraints:
          - node.labels.nodelabels == Middleware
      restart_policy:
        condition: on-failure
    networks: 
      - middleware
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
networks:
  middleware:
    external: true
    name: macrowing
