version: "3.8"

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.8.1
    ports:
      - "9200:9200"
    volumes:
      - ./data:/usr/share/elasticsearch/data
    environment:
      - node.name=es1
      - cluster.name=docker-cluster
      - cluster.initial_master_nodes=es1
      - bootstrap.memory_lock=true
      - script.painless.regex.enabled=true
      - ES_JAVA_OPTS=-Xms8g -Xmx8g
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: unless-stopped

  logstash:
    image: docker.elastic.co/logstash/logstash:7.8.1
    ports:
      - "5044:5044"
      - "9600:9600"
      - "12201:12201/udp"
    volumes:
      - ./data/pipelines.yml:/usr/share/logstash/config/pipelines.yml
      - ./data/pipelines:/usr/share/logstash/pipelines
    environment:
      - node.name=ls1
      - xpack.monitoring.enabled=true
      - xpack.monitoring.elasticsearch_hosts=[http://elasticsearch:9200]
      - LS_JAVA_OPTS=-Xms4g -Xmx4g
    depends_on:
      - elasticsearch
    restart: unless-stopped

  kibana:
    image: docker.elastic.co/kibana/kibana:7.8.1
    ports:
      - "5601:5601"
    environment:
      - SERVER_NAME=kibana
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    depends_on:
      - elasticsearch
    restart: unless-stopped

  apm-server:
    image: docker.elastic.co/apm/apm-server:7.8.1
    ports:
      - "8200:8200"
    volumes:
      - ./data/apm-server.yml:/usr/share/apm-server/apm-server.yml
    depends_on:
      - elasticsearch
    restart: unless-stopped
