version: "3.3"
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:${CONFLUENT_DOCKER_TAG}
    restart: always
    hostname: zookeeper
    container_name: zookeeper
    environment:
      ZOOKEEPER_SERVER_ID: 1
      ZOOKEEPER_CLIENT_PORT: "2181"
      ZOOKEEPER_TICK_TIME: "2000"
    ports:
      - "2181:2181"
  kafka:
    image: confluentinc/cp-server:${CONFLUENT_DOCKER_TAG}
    hostname: kafka
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      - "10091:10091"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:10091
      KAFKA_BROKER_ID: 1
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_DELETE_TOPIC_ENABLE: "true"
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
      KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: "false"
  schemaregistry:
    image: confluentinc/cp-schema-registry:${CONFLUENT_DOCKER_TAG}
    container_name: schemaregistry
    restart: always
    depends_on:
      - kafka
    environment:
      SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "kafka:10091"
      SCHEMA_REGISTRY_HOST_NAME: schemaregistry
      SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8085"
      SCHEMA_REGISTRY_KAFKASTORE_SECURITY_PROTOCOL: PLAINTEXT
      SCHEMA_REGISTRY_MODE_MUTABILITY: "true"
      SCHEMA_REGISTRY_LOG4J_ROOT_LOGLEVEL: INFO
    ports:
      - 8085:8085
  registry-client:
    image: python:3
    hostname: registry-client
    container_name: registry-client
    depends_on:
      - schemaregistry
    volumes:
      - ../..:/app  
    command: "bash -c -a 'sleep 30 && \
                       pip3 install -r /app/scripts/requirements.txt && \
                       python3 /app/scripts/proto_schemas.py --mode mock
                       '"
    environment:
      # The following settings are listed here only to satisfy the image's requirements.
      KAFKA_BROKER_ID: ignored
      KAFKA_ZOOKEEPER_CONNECT: ignored
      KAFKA_ADVERTISED_LISTENERS: ignored

