services:
  kafka:
    image: apache/kafka:latest
    restart: unless-stopped
    network_mode: host
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      KAFKA_NODE_ID: 1
      KAFKA_PROCESS_ROLES: broker,controller
      KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

  kafdrop:
    image: obsidiandynamics/kafdrop:latest
    restart: unless-stopped
    depends_on:
      - kafka
    network_mode: host
    extra_hosts:
      - "host.docker.internal:host-gateway"
    command: sh -c "sleep 5 && exec ./start-app"
    environment:
      KAFKA_BROKERCONNECT: "localhost:9092"
