version: '3.5'

services:
### SVC:apm:>>>
  apm:
    hostname: apm
    image: registry.edoc2.com:5000/edoc2v5/apm:ecm-apm-ChangJiang-v6.1.0.0 
    networks:
      - macrowing
    ports:
      - "8083:80"
    volumes:
      - /var/run/docker.sock:/app/docker.sock
    env_file:
      ./envfile.env
    environment:
      # - ECM_ESURL=http://192.168.20.125:30003
      - MiddlewareIsCluster=0
      - IsUsedGRPC=1
      - FilterContainer=inwise
#      - DatabaseType=1
#      - DatabaseServerName=sqlserver
#      - DatabaseServerPort=1433
#      - DatabaseUserName=sa
#      - DatabasePassword=1qaz2WSX
    deploy:
      placement:
        constraints:
          - node.role == manager
      replicas: 1
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '2'
          memory: 4G
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:apm:<<<
### SVC:basic:>>>
  basic:
    image: registry.edoc2.com:5000/edoc2v5/metricbasic:ecm-apm-ChangJiang-v6.1.0.0
    user: root
    volumes:
      - type: bind
        source: /proc
        target: /hostfs/proc
        read_only: true
      - type: bind
        source: /sys/fs/cgroup
        target: /hostfs/sys/fs/cgroup
        read_only: true
      - type: bind
        source: /
        target: /hostfs
        read_only: true
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        read_only: true
    # environment:
      # 使用内置的ecm es，ELASTICSEARCH_HOSTS 不要配置
      # - ELASTICSEARCH_HOSTS=es:9200
      # - ELASTICSEARCH_HOSTS=http://192.168.20.125:30003
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '1'
          memory: 256M
    networks:
      - hostnet
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:basic:<<<
### SVC:heartbeat:>>>
  heartbeat:
    hostname: heartbeat
    image: registry.edoc2.com:5000/edoc2v5/heartbeat:ecm-apm-ChangJiang-v6.1.0.0
    environment:
      - ELASTICSEARCH_HOSTS=es:9200
      # - ELASTICSEARCH_HOSTS=http://192.168.20.125:30003
    networks: 
      - macrowing
#    extra_hosts:
#      - "redis1:x"
#      - "redis2:x"
#      - "redis3:x"
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '1'
          memory: 256M
    healthcheck:
      test: curl -s -L -k -i http://apm/apm/env | grep "200 OK"
      interval: 20s
      timeout: 10s
      retries: 5 
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:heartbeat:<<<
### SVC:filebeat:>>>
  filebeat:
    hostname: filebeat
    image: registry.edoc2.com:5000/edoc2v5/filebeat:ecm-apm-ChangJiang-v6.1.0.0
    environment:
      - ELASTICSEARCH_HOSTS=es:9200
      # - ELASTICSEARCH_HOSTS=http://192.168.20.125:30003
    volumes:
      - /var/log/:/hostfs/var/log/
      - /tmp:/usr/share/filebeat/data
    networks: 
      - macrowing
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '1'
          memory: 256M 
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:filebeat:<<
### SVC:middleware:>>>
  middleware:
    hostname: middleware
    image: registry.edoc2.com:5000/edoc2v5/metricmiddle:ecm-apm-ChangJiang-v6.1.0.0
    environment:
      - ELASTICSEARCH_HOSTS=es:9200
      # - ELASTICSEARCH_HOSTS=http://192.168.20.125:30003
    networks: 
      - macrowing
#    extra_hosts:
#      - "redis1:x"
#      - "redis2:x"
#      - "redis3:x"
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '1'
          memory: 256M
    healthcheck:
      test: curl -s -L -k -i http://apm/apm/env | grep "200 OK"
      interval: 20s
      timeout: 10s
      retries: 5 
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:middleware:<<<
### SVC:logstash:>>>
  logstash:
    hostname: logstash
    image: registry.edoc2.com:5000/edoc2v5/logstash:ecm-apm-ChangJiang-v6.1.0.0
    environment:
      # - ELASTICSEARCH_HOSTS=http://192.168.20.125:30003
      - USED_MYSQL=true
      - LS_JAVA_OPTS=-Xms2g -Xmx2g
      - COLLECT_LOG_SERVICES=["edoc2","content","unionsync","orgsync","transport","regionsync","decryption","edrms","inbiz","auth","perm","org"]
      - API_LOG_MODULE=["WebAPI","CoreAPI","DB","EDoc2.PermCtrl","EDoc2.Cache","EDRMS-DB","EDRMS-WEBAPI"]
    ports:
      - "55514:55514/udp"
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: '2'
          memory: 4G
    networks:
      - macrowing
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"
### SVC:logstash:<<<

networks:
  hostnet:
    external: true
    name: host
  macrowing:
    external: true
    name: macrowing