version: "3.6"
services:

  zookeeper:
    image: '192.168.13.196:9000/zookeeper:3.6.2'
    restart: always
    ports:
      - 2181:2181
    volumes:
      - "zookeeper_data:/bitnami/zookeeper"
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
    logging:
      options:
        max-size: 1G
    healthcheck:
     test: ["CMD", "sh", "-c", "nc -z -w5 localhost 2181"]
     interval: 5s
     timeout: 3s
     retries: 3

  kafka:
    image: '192.168.13.196:9000/kafka:2.8.0'
    restart: always
    #network_mode: "host"
    ports:
      - 9092:9092
    volumes:
      - "kafka_data:/bitnami"
    environment:
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      ALLOW_PLAINTEXT_LISTENER: "yes"
      # KAFKA_CONF_FILE: "/opt/bitnami/kafka/config/server.properties"
      KAFKA_LOG_RETENTION_BYTES: 50000000
      KAFKA_LOG_SEGMENT_BYTES: 50000000
      # KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 30000
      KAFKA_CFG_LOG_RETENTION_CHECK_INTERVAL_MS: 30000
      KAFKA_CFG_LOG_CLEANER_DELETE_RETENTION_MS: 5000
      KAFKA_CFG_LOG_CLEANER_MAX_COMPACTION_LAG_MS: 20000
      KAFKA_CFG_LOG_RETENTION_MS: 60000
      KAFKA_CFG_OFFSETS_RETENTION_CHECK_INTERVAL_MS: 120000
      KAFKA_CFG_UNCLEAN_LEADER_ELECTION_ENABLE: "true"
      # KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "false"
      KAFKA_CFG_OFFSETS_RETENTION_MINUTES: 1
      LOG_RETENTION_CHECK_INTERVAL_MS: 30000
      KAFKA_HEAP_OPTS: -Xmx1G -Xms1G
    depends_on:
      - zookeeper
    logging:
      options:
        max-size: 1G
    healthcheck:
      test: ["CMD", "kafka-topics.sh", "--bootstrap-server", "localhost:9092", "--list"]
      interval: 5s
      timeout: 3s
      retries: 3
      start_period: 30s


volumes:
  kafka_data:
  zookeeper_data:
