---
version: '2'
volumes:
  postgre_apicurio:

services:
  zookeeper:
    image: confluentinc/cp-zookeeper:7.2.1
    hostname: zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    cap_drop:
      - NET_RAW


  kafka-connect0:
    restart: "unless-stopped"
    image: debezium/connect:nightly
    depends_on:
      - broker
    ports:
      - "8083:8083"
    environment:
      GROUP_ID: 2
      BOOTSTRAP_SERVERS: "broker:9092"
      CONFIG_STORAGE_TOPIC: dbz_connect_configs
      OFFSET_STORAGE_TOPIC: dbz_connect_offsets
      ENABLE_APICURIO_CONVERTERS: "true"
      KEY_CONVERTER: io.apicurio.registry.utils.converter.AvroConverter
      VALUE_CONVERTER: io.apicurio.registry.utils.converter.AvroConverter
      CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8080/apis/registry/v2
      CONNECT_KEY_CONVERTER: io.apicurio.registry.utils.converter.AvroConverter
      CONNECT_KEY_CONVERTER_APICURIO.REGISTRY_URL: http://schema-registry:8080/apis/registry/v2
      CONNECT_KEY_CONVERTER_APICURIO_REGISTRY_AUTO-REGISTER: "true"
      CONNECT_KEY_CONVERTER_APICURIO_REGISTRY_FIND-LATEST: "true"
      CONNECT_VALUE_CONVERTER: io.apicurio.registry.utils.converter.AvroConverter
      CONNECT_VALUE_CONVERTER_APICURIO_REGISTRY_URL: http://schema-registry:8080/apis/registry/v2
      CONNECT_VALUE_CONVERTER_APICURIO_REGISTRY_AUTO-REGISTER: "true"
      CONNECT_VALUE_CONVERTER_APICURIO_REGISTRY_FIND-LATEST: "true"
      CONNECT_SCHEMA_NAME_ADJUSTMENT_MODE: avro
    cap_drop:
      - NET_RAW

  broker:
    image: confluentinc/cp-kafka:7.2.1
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    ports:
      - "29092:29092"
      - "9092:9092"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
    cap_drop:
      - NET_RAW


    # Schema Registry
  schema-registry:
    image: apicurio/apicurio-registry-sql:2.6.x-release
    restart: always
    ports:
      - "8080:8080"
    environment:
      REGISTRY_DATASOURCE_URL: "jdbc:postgresql://apicurio-db/apicuriodb"
      REGISTRY_DATASOURCE_USERNAME: "postgres"
      REGISTRY_DATASOURCE_PASSWORD: "postgres"
      SCHEMA_REGISTRY_HOST_NAME: schema-registry
      SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: divolte-kafka:2181
    cap_drop:
      - NET_RAW

  kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:master
    ports:
      - "8081:8080"
    depends_on:
      - broker
      - schema-registry
      - kafka-connect0
    environment:
      KAFKA_CLUSTERS_0_NAME: local
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "broker:9092"
      KAFKA_CLUSTERS_0_SCHEMAREGISTRY: "http://schema-registry:8080/apis/ccompat/v6"
      KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: first
      KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: "http://kafka-connect0:8083"
      KAFKA_CLUSTERS_0_KSQLDBSERVER: "http://ksqldb-server:8088"
    cap_drop:
      - NET_RAW

  ksqldb-server:
    image: confluentinc/ksqldb-server:0.28.2
    hostname: ksqldb-server
    container_name: ksqldb-server
    depends_on:
      - broker
    ports:
      - "8088:8088"
    environment:
      KSQL_LISTENERS: http://0.0.0.0:8088
      KSQL_BOOTSTRAP_SERVERS: broker:9092
      KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
      KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
      KSQL_KSQL_SCHEMA_REGISTRY_URL: "http://schema-registry:8080/apis/ccompat/v6"
    cap_drop:
      - NET_RAW

  ksqldb-cli:
    image: confluentinc/ksqldb-cli:0.28.2
    container_name: ksqldb-cli
    depends_on:
      - broker
      - ksqldb-server
    entrypoint: /bin/sh
    tty: true
    cap_drop:
      - NET_RAW

  apicurio-db:
    ports:
      - '5432:5432'
    image: 'postgres:latest'
    environment:
      POSTGRES_DB: apicuriodb
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - 'postgre_apicurio:/var/lib/postgresql/data'
    command:
      - "postgres"
      - "-c"
      - "wal_level=logical"
    cap_drop:
      - NET_RAW
