version: "2"

services:
  # MongoDB: https://hub.docker.com/_/mongo/
  graylog-mongo:
    image: docker.io/mongo:4.2
    container_name: graylog-mongo
    hostname: mongo
    ports:
      - 27017:27017
    privileged: true
    restart: unless-stopped
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=drUqGGCMh
    volumes:
      - /home/graylog/data/mongo:/data/db
      - /home/graylog/graylog.js:/docker-entrypoint-initdb.d/graylog.js:ro
    env_file: .env

  # Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docker.html
  graylog-elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
    container_name: graylog-elasticsearch
    hostname: elasticsearch
    #ports:
    #  - 9200:9200
    privileged: true
    restart: unless-stopped
    environment:
      - http.host=0.0.0.0
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - transport.host=localhost
      - network.host=0.0.0.0
      - "ES_JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true -Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 1g
    volumes:
      - /home/graylog/data/elasticsearch:/usr/share/elasticsearch/data
    env_file: .env
    depends_on:
      - graylog-mongo

  # Graylog: https://hub.docker.com/r/graylog/graylog/
  graylog-server:
    image: docker.io/graylog/graylog:4.3
    container_name: graylog-server
    hostname: graylog
    entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 --  /docker-entrypoint.sh
    ports:
      # Graylog web interface and REST API
      - 7555:7555
      # Syslog TCP
      - 1514:1514
      # Syslog UDP
      - 1514:1514/udp
      # GELF TCP
      - 12201:12201
      # GELF UDP
      - 12201:12201/udp
    privileged: true
    restart: unless-stopped
    environment:
      # CHANGE ME (must be at least 16 characters)!
      - GRAYLOG_PASSWORD_SECRET=324bde1b479a08f7
      # Password: admin
      - GRAYLOG_ROOT_PASSWORD_SHA2=34d7c08069cc011fa0d17481aab22868f25ac3b8bbc38f03877b695ebca09af9
      - GRAYLOG_HTTP_BIND_ADDRESS=0.0.0.0:7555
      - GRAYLOG_HTTP_EXTERNAL_URI=https://graylog.chiefsoft.net/
      - GRAYLOG_TRANSPORT_EMAIL_WEB_INTERFACE_URL=https://graylog.chiefsoft.net/
      - GRAYLOG_TRANSPORT_EMAIL_HOSTNAME=smtp.gmail.com
      - GRAYLOG_TRANSPORT_EMAIL_ENABLED=true
      - GRAYLOG_TRANSPORT_EMAIL_PORT=587
      - GRAYLOG_TRANSPORT_EMAIL_USE_AUTH=true
      - GRAYLOG_TRANSPORT_EMAIL_USE_TLS=true
      - GRAYLOG_TRANSPORT_EMAIL_USE_SSL=false
      - GRAYLOG_TRANSPORT_FROM_EMAIL=support@chiefsoft.com
      - GRAYLOG_TRANSPORT_AUTH_USERNAME=support@chiefsoft.com
      - GRAYLOG_TRANSPORT_AUTH_PASSWORD=tbnedulxgycvvjhu
      - GRAYLOG_TRANSPORT_SUBJECT_PREFIX=[graylog]
      - GRAYLOG_MONGODB_URI=mongodb://graylog:vWGzncmBe9@mongo:27017/graylog
      - GRAYLOG_MESSAGE_JOURNAL_ENABLED=false
    volumes:
      - /home/graylog/data/journal:/usr/share/graylog/data/journal
      - /home/graylog/config:/usr/share/graylog/data/config
      - /home/graylog/plugin:/usr/share/graylog/plugin
    env_file: .env
    links:
      - graylog-mongo:mongo
      - graylog-elasticsearch:elasticsearch
    depends_on:
      - graylog-mongo
      - graylog-elasticsearch


