version: "3"

services:
  kafka:
    container_name: kafka
    hostname: kafka
    image: bitnami/kafka:latest
    ports:
      # Flip the ports around, external gets default.
      - "9092:9094"
      - "9094:9092"
    #network_mode: host
    networks:
      - kafka-internal
    volumes:
      - "kafka_data:/bitnami"
    environment:
      - ALLOW_PLAINTEXT_LISTENER=yes
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
      - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true

  kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:latest
    ports:
      - 8080:8080
    networks:
      - kafka-internal
    environment:
      DYNAMIC_CONFIG_ENABLED: 'true'
      KAFKA_CLUSTERS_0_NAME: test
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
    depends_on:
      - kafka
    volumes:
      - ~/kui/config.yml:/etc/kafkaui/dynamic_config.yaml


#  magic:
#    image: "digitsy/kafka-magic"
#    ports:
#      - "8080:80"
#    networks:
#      - kafka-internal
#    volumes:
#      - .:/config
#    environment:
#      KMAGIC_ALLOW_TOPIC_DELETE: "true"
#      KMAGIC_ALLOW_SCHEMA_DELETE: "true"
#      KMAGIC_CONFIG_STORE_TYPE: "file"
#      KMAGIC_CONFIG_STORE_CONNECTION: "Data Source=/config/KafkaMagicConfig.db;"
#      KMAGIC_CONFIG_ENCRYPTION_KEY: "ENTER_YOUR_KEY_HERE"


volumes:
  kafka_data:
    driver: local

networks:
  kafka-internal: