version: '2.4'

services:
  elasticsearch:
    user: 1002:1002 #develuser
    restart: unless-stopped
    mem_limit: 2048m
    environment:
      - cluster.name=open-dmp-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xmx1024m -Xms1024m"
      - xpack.license.self_generated.type=basic 
      - xpack.monitoring.collection.enabled=true
      - xpack.security.enabled=true
    ulimits:
      nproc: 65535
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./shared/config-elk/elasticsearch/config/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties:ro
      - ./shared/config-elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
      - ./shared/data-elk/elasticsearch-01-data:/usr/share/elasticsearch/data
      - ./shared/data-elk/elasticsearch-01-log:/usr/share/elasticsearch/logs
    #ports:
    #  - 51056:9200
    #  - 51057:9300
    ports:
      - "9200:9200"
    expose:
      - "9300"
    networks:
      open-dmp-elk-network:
    
  logstash:
    # user: 1002:1002 #develuser
    volumes:
      - ./shared/config-elk/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
      - ./shared/config-elk/logstash/config/pipelines.yml:/usr/share/logstash/config/pipelines.yml:ro
      - ./shared/config-elk/logstash/config/log4j2.properties:/usr/share/logstash/config/log4j2.properties:ro
      - ./shared/config-elk/logstash/pipeline:/usr/share/logstash/pipeline:ro
      - ./shared/config-elk/logstash/logstash/templates:/usr/share/logstash/templates
      - ./shared/data-elk/logstash-log:/usr/share/logstash/logs
      - ./shared/data-elk/logstash-queue:/usr/share/logstash/queue
      - ./shared/data-elk/logstash-dead_letter_queue:/usr/share/logstash/dead_letter_queue
    expose:
      - "31311"
      - "31312"
    restart: on-failure
    mem_limit: 2048m
    environment:
      - LS_JAVA_OPTS=-Xmx1024m -Xms1024m
      - xpack.license.self_generated.type=basic 
      - xpack.security.enabled=true
    networks:
      open-dmp-elk-network:

  kibana:
    # user: 1002:1002 #develuser
    mem_limit: 512m
    environment:
      - xpack.license.self_generated.type=basic 
      - xpack.security.enabled=true
      
    volumes:
      - ./shared/config-elk/kibana/config:/usr/share/kibana/config:ro
      #- ./shared/config-elk/kibana/certificates:/usr/share/kibana/certificates
    restart: unless-stopped
    ports:
      - "51058:5601"
    networks:
      - open-dmp-elk-network

  filebeat:
    restart: unless-stopped
    mem_limit: 256m
    #command: [ "-e=false" ] # to overwrite the -e that disables logging to file!
    volumes:
      - ./shared/config-elk/filebeat/config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
      - ~/openDMP/logs:/usr/share/filebeat/log_data/dmp/
      - ./shared/data-elk/filebeat-log:/usr/share/filebeat/logs
      - ./shared/data-elk/filebeat-data:/usr/share/filebeat/data #For windows if we mount the data  directory we get "Writing of registry returned error: sync /usr/share/filebeat/data/registry/filebeat: invalid argument."
    networks:
      - open-dmp-elk-network

networks:
  open-dmp-elk-network:
