version: "3.8"

services:

  zookeeper:
    image: confluentinc/cp-zookeeper:5.5.1
    hostname: zookeeper
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
    volumes:
      - ./data/zookeeper:/var/lib/zookeeper/data
    environment:
      - ZOOKEEPER_CLIENT_PORT=2181
      - ZOOKEEPER_TICK_TIME=2000
      - ZOOKEEPER_SYNC_LIMIT=2
    restart: unless-stopped

  kafka:
    image: confluentinc/cp-kafka:5.5.1
    hostname: kafka
    ports:
      - "9092:9092"
    volumes:
      - ./data/kafka:/var/lib/kafka/data
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
      - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
    depends_on:
      - zookeeper
    restart: unless-stopped

  schema-registry:
    image: confluentinc/cp-schema-registry:5.5.1
    hostname: schema-registry
    ports:
      - "8081:8081"
    environment:
      - SCHEMA_REGISTRY_HOST_NAME=schema-registry
      - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181
      - SCHEMA_REGISTRY_LISTENERS=http://0.0.0.0:8081
      - SCHEMA_REGISTRY_ACCESS_CONTROL_ALLOW_METHODS=GET,POST,PUT,OPTIONS
      - SCHEMA_REGISTRY_ACCESS_CONTROL_ALLOW_ORIGIN=*
    depends_on:
      - zookeeper
      - kafka
    restart: unless-stopped

  schema-registry-ui:
    image: landoop/schema-registry-ui
    hostname: schema-registry-ui
    ports:
      - "8000:8000"
    environment:
      - SCHEMAREGISTRY_URL=http://schema-registry:8081
    depends_on:
      - schema-registry
    restart: unless-stopped
