---
version: '3'
services:
##########################ELASTIC######################################################################
  elasticsearch-dmp:
    image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
    container_name: elasticsearch-dmp
    volumes:
          - ./elastic-config/elasticsearch-custom.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    environment: ['http.host=0.0.0.0','transport.host=0.0.0.0','discovery.type=single-node']
    ports: ['0.0.0.0:9201:9200','0.0.0.0:9301:9300']
    networks: ['elasticsearch-dmp']
    volumes:
      - esdata-dmp:/usr/share/elasticsearch/data

##########################ELK-STACK######################################################################

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
    container_name: elasticsearch
    environment: ['http.host=0.0.0.0', 'transport.host=127.0.0.1', 'ELASTIC_PASSWORD=${ELASTIC_PASSWORD}','discovery.type=single-node']
    ports: ['0.0.0.0:9200:9200']
    networks: ['stack']
    volumes:
      - esdata:/usr/share/elasticsearch/data

  kibana:
    image: docker.elastic.co/kibana/kibana:${TAG}
    container_name: kibana
    ports: ['0.0.0.0:5601:5601']
    networks: ['stack']
    depends_on: ['elasticsearch']

  logstash:
    image: docker.elastic.co/logstash/logstash:${TAG}
    container_name: logstash
    volumes:
      - ./ELK.Docker/config/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
    ports: ['0.0.0.0:31311:31311']

    networks: ['stack']
    depends_on: ['elasticsearch', 'setup_logstash']

  #filebeat:
  #  image: docker.elastic.co/beats/filebeat:${TAG}
  #  container_name: filebeat
  #  command: -e -E 'output.elasticsearch.password=${ELASTIC_PASSWORD}'
  #  networks: ['stack']
  #  depends_on: ['elasticsearch', 'setup_filebeat']

  #heartbeat:
  #  image: docker.elastic.co/beats/heartbeat:${TAG}
  #  container_name: heartbeat
  #  command: -e -E 'output.elasticsearch.password=${ELASTIC_PASSWORD}'
  #  networks: ['stack']
  #  depends_on: ['elasticsearch', 'setup_heartbeat']

  # Run a short-lived container to set up Logstash.
  setup_logstash:
    image: centos:7
    container_name: setup_logstash
    volumes: ['./ELK.Docker/scripts/setup-logstash.sh:/usr/local/bin/setup-logstash.sh:ro']
    command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-logstash.sh | tr -d "\r" | bash']
    environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
    networks: ['stack']
    depends_on: ['elasticsearch']

  setup_kibana:
    image: centos:7
    container_name: setup_kibana
    volumes: ['./ELK.Docker/scripts/setup-kibana.sh:/usr/local/bin/setup-kibana.sh:ro']
    command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-kibana.sh | tr -d "\r" | bash']
    environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
    networks: ['stack']
    depends_on: ['elasticsearch']

  #setup_filebeat:
  #  image: docker.elastic.co/beats/filebeat:${TAG}
  #  container_name: setup_filebeat
  #  volumes: ['./ELK.Docker/scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro']
  #  command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-beat.sh | tr -d "\r" | bash -s filebeat']
  #  environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
  #  networks: ['stack']
  #  depends_on: ['kibana']

  #setup_heartbeat:
  #  image: docker.elastic.co/beats/heartbeat:${TAG}
  #  container_name: setup_heartbeat
  #  volumes: ['./ELK.Docker/scripts/setup-beat.sh:/usr/local/bin/setup-beat.sh:ro']
  #  command: ['/bin/bash', '-c', 'cat /usr/local/bin/setup-beat.sh | tr -d "\r" | bash -s heartbeat']
  #  environment: ['ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
  #  networks: ['stack']
  #  depends_on: ['kibana']

##########################DOCSBOX######################################################################
  # web:
    # restart: always
    # build: ./docsbox-master/docsbox
    # expose:
      # - "8000"
    # links:
      # - redis:redis
    # volumes:
      # - docsbox:/home/docsbox
      # - media:/home/docsbox/media
    # command: gunicorn -b :8000 docsbox:app
    # networks: ['stack']

  # rqworker:
    # restart: always
    # build: ./docsbox-master/docsbox
    # links:
      # - redis:redis
    # volumes:
      # - web
    # command: rq worker -c docsbox.settings
    # networks: ['stack']

  # rqscheduler:
    # restart: always
    # build: ./docsbox-master/docsbox
    # links:
      # - redis:redis
    # volumes:
      # - web
    # command: rqscheduler -H redis -p 6379 -d 0
    # networks: ['stack']

  # nginx:
    # restart: always
    # build: ./docsbox-master/nginx/
    # ports:
      # - "81:80"
    # volumes:
      # - web
    # links:
      # - web:web
    # networks: ['stack']

  # redis:
    # restart: always
    # image: redis:latest
    # expose:
      # - "6379"
    # volumes:
      # - redisdata:/data
    # networks: ['stack']


##########################SETTINGS######################################################################

volumes:
  esdata:
    driver: local
  esdata-dmp:
    driver: local
  #redisdata:
  #  driver: local
  # docsbox:
    # driver: local
  # media:
    # driver: local
networks: 
    stack: {}
    elasticsearch-dmp: {}



