version: '2'

services:

  # MongoDB: https://hub.docker.com/_/mongo/
  mongodb:
    image: mongo:4.2
    volumes:
      - mongo_data:/data/db

  # Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/6.x/docker.html
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1
    mem_limit: 4g
    restart: always
    volumes:
      - es_data:/usr/share/elasticsearch/data
    env_file:
      - ./elasticsearch.env
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200

  # Graylog: https://hub.docker.com/r/graylog/graylog/
  graylog:
    build: 
      context: ./graylog/.
    volumes:
      - graylog_journal:/usr/share/graylog/data/journal
      - ./graylog/service-names-port-numbers.csv:/etc/graylog/server/service-names-port-numbers.csv
    env_file:
      - ./graylog.env
    entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 --  /docker-entrypoint.sh
    links:
      - mongodb:mongo
      - elasticsearch
    restart: always
    depends_on:
      - mongodb
      - elasticsearch
    ports:
      # Netflow
      - 2055:2055/udp
      # Syslog Feed
      - 5442:5442/udp
      # Graylog web interface and REST API
      - 9000:9000
      # Syslog TCP
      - 1514:1514
      # Syslog UDP
      - 1514:1514/udp
      # GELF TCP
      - 12201:12201
      # GELF UDP
      - 12201:12201/udp

  # Kibana : https://www.elastic.co/guide/en/kibana/6.8/index.html
  kibana:
    image: docker.elastic.co/kibana/kibana:7.11.1
    entrypoint: ["echo", "Service Kibana disabled"]
    env_file:
      - kibana.env
    depends_on:
      - elasticsearch
    ports:
      - 5601:5601
  cerebro:
    image: lmenezes/cerebro
#    entrypoint: ["echo", "Service cerebro disabled"]
    ports:
      - 9001:9000
    links:
      - elasticsearch
    depends_on:
      - elasticsearch
    logging:
      driver: "json-file"
      options:
        max-size: "100M"

  influxdb:
    image: 'influxdb:latest'
    env_file:
      - ./influxdb.env
    ports:
      - 8086:8086
    volumes:
      - influxdb:/var/lib/influxdb
    logging:
      driver: "json-file"
      options:
        max-size: "100M"

  grafana:
    image: grafana/grafana:latest
    env_file:
      - ./grafana.env
    ports:
      - 3000:3000
    volumes:
      - grafana:/var/lib/grafana
      - ./grafana/provisioning/:/etc/grafana/provisioning
    links:
      - elasticsearch
      - influxdb
    depends_on:
      - elasticsearch
      - influxdb
    logging:
      driver: "json-file"
      options:
        max-size: "100M"

# Volumes for persisting data, see https://docs.docker.com/engine/admin/volumes/volumes/
volumes:
  mongo_data:
    driver: local
  es_data:
    driver: local
  graylog_journal:
    driver: local
  grafana:
    driver: local
  influxdb:
    driver: local
