# See https://hub.docker.com/r/bitnamilegacy/kafka/tags for the complete list.
version: '3'
services:
  kafka:
    container_name: kafka
    image: bitnamilegacy/kafka:4.0.0
    restart: on-failure:3
    ports:
      - 9092:9092
      - 9093:9093
    environment:
      KAFKA_CFG_NODE_ID: 1
      KAFKA_CFG_BROKER_ID: 1
      KAFKA_CFG_PROCESS_ROLES: broker,controller
      KAFKA_CFG_ADVERTISED_HOST_NAME: 'localhost'
      KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAIN:PLAINTEXT,SASL:SASL_PLAINTEXT
      KAFKA_CFG_LISTENERS: CONTROLLER://:9094,PLAIN://:9092,SASL://:9093
      KAFKA_CFG_ADVERTISED_LISTENERS: PLAIN://localhost:9092,SASL://localhost:9093
      KAFKA_CFG_INTER_BROKER_LISTENER_NAME: PLAIN
      KAFKA_CFG_SASL_ENABLED_MECHANISMS: 'PLAIN,SCRAM-SHA-256,SCRAM-SHA-512'
      KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@localhost:9094
      ALLOW_PLAINTEXT_LISTENER: yes
      KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: 'true'
      KAFKA_OPTS: "-Djava.security.auth.login.config=/opt/bitnami/kafka/config/kafka_jaas.conf"
      KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'true'
      KAFKA_CFG_DELETE_TOPIC_ENABLE: 'true'
      KAFKA_CFG_MESSAGE_MAX_BYTES: '200000000'
      KAFKA_CFG_AUTHORIZER_CLASS_NAME: 'org.apache.kafka.metadata.authorizer.StandardAuthorizer'
      KAFKA_CFG_SUPER_USERS: User:adminscram256;User:adminscram512;User:adminplain
      KAFKA_CLIENT_USERS: adminscram256,adminscram512,adminplain
      KAFKA_CLIENT_PASSWORDS: admin-secret-256,admin-secret-512,admin-secret
      KAFKA_CLIENT_SASL_MECHANISMS: SCRAM-SHA-256,SCRAM-SHA-512,PLAIN
      KAFKA_INTER_BROKER_USER: adminscram512
      KAFKA_INTER_BROKER_PASSWORD: admin-secret-512
      KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: SCRAM-SHA-512
      # Note you will need to increase this to at least 4GB of memory for the tests to pass
      # https://github.com/segmentio/kafka-go/issues/1360#issuecomment-2858935900
      KAFKA_HEAP_OPTS: '-Xmx1000m -Xms1000m'
      KAFKA_JVM_OPTS: '-XX:+UseG1GC'