---
version: '3'
services:
  # The environment variable "TAG" is used throughout this file to
  # specify the version of the images to run. The default is set in the
  # '.env' file in this folder. It can be overridden with any normal
  # technique for setting environment variables, for example:
  #
  #   TAG=6.0.0-beta1 docker-compose up
  #
  # REF: https://docs.docker.com/compose/compose-file/#variable-substitution
  #
  # Also be sure to set the ELASTIC_VERSION variable. For released versions,
  # ${TAG} and ${ELASTIC_VERSION} will be identical, but for pre-release
  # versions, ${TAG} might contain an extra build identifier, like
  # "6.0.0-beta1-3eab5b40", so a full invocation might look like:
  #
  #   ELASTIC_VERSION=6.0.0-beta1 TAG=6.0.0-beta1-3eab5b40 docker-compose up
  #
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
    container_name: elasticsearch
    #volumes:
     # - esdata:/usr/share/elasticsearch/data
    environment: ['http.host=0.0.0.0', 'transport.host=127.0.0.1', 'ELASTIC_PASSWORD=${ELASTIC_PASSWORD}']
    ports: ['0.0.0.0:9200:9200']
    networks: ['stack']

  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
    # Provide a simple pipeline configuration for Logstash with a bind-mounted file.
    volumes:
      - ./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}'
    # If the host system has logs at "/var/log", mount them at "/mnt/log"
    # inside the container, where Filebeat can find them.
    # volumes: ['/var/log:/mnt/log:ro']
    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: ['./scripts/setup-logstash.sh:/usr/local/bin/setup-logstash.sh:ro']
    # The script may have CR/LF line endings if using Docker for Windows, so
    # make sure that they don't confuse Bash.
    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: ['./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: ['./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: ['./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']


##########################SETTIGNS######################################################################

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

