version: "3"
services:
  fluentd:
    container_name: fluentd
    user: root
    build:
      context: .
    image: fluentd
    volumes:
    - /var/lib/docker/containers:/fluentd/log/containers # Example: Reading docker logs
    - ./file:/fluentd/log/files/ #Example: Reading logs from a file
    - ./configurations:/fluentd/etc/
    - ./logs:/output/ # Example: Fluentd will collect logs and store it here for demo
    logging:
      driver: "local"
  # This app sends logs to Fluentd via HTTP
  http-myapp:
    container_name: http-myapp
    image: alpine
    volumes:
    - ./http:/app
    command: [ /bin/sh , -c , "apk add --no-cache curl && chmod +x /app/app.sh && ./app/app.sh"]
  # This app writes logs to a local file
  file-myapp:
    container_name: file-myapp
    image: alpine
    volumes:
    - ./file:/app
    command: [ /bin/sh , -c , "chmod +x /app/app.sh && ./app/app.sh"]
  elasticsearch: # port 9200
    image: elasticsearch:7.9.1
    container_name: elasticsearch
    environment:
    - node.name=elasticsearch
    - cluster.initial_master_nodes=elasticsearch
    - bootstrap.memory_lock=true
    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
  kibana:
    image: kibana:7.9.1
    container_name: kibana
    ports:
      - "5601:5601"
    environment:
      ELASTICSEARCH_URL: http://elasticsearch:9200
      ELASTICSEARCH_HOSTS: http://elasticsearch:9200