services:
  # Data Base Systems
  #
  # Informix DB
  informix:
    # *-----------------------------*
    # To connect to the DB:
    #   $ docker-compose exec informix bash
    #
    # To display logs:
    #   $ docker logs -f informix
    # *-----------------------------*
    # Create schemas:
    # docker-compose exec informix bash -c '/docker-entrypoint-initdb.d/schema.sh'
    # docker-compose exec informix bash -c '/docker-entrypoint-initdb.d/schema2.sh'
    #
    # Populate data
    # docker-compose exec informix bash -c '/docker-entrypoint-initdb.d/insert.sh'
    # docker-compose exec informix bash -c '/docker-entrypoint-initdb.d/insert2.sh'
    #
    # User: informix
    # Pass: in4mix
    #
    # Informix needs to be set for CDC. To do that one needs to run the SQL script
    # syscdcv1.sql located at /opt/ibm/informix/etc
    #
    # To run it, you will need dbaccess, the command is:
    #   $ dbaccess - syscdcv1.sql
    #
    # You might need to re-set the PATH env variable
    #   $ export PATH=$PATH:/opt/ibm/informix/bin
    #
    # Docker Hub: https://hub.docker.com/r/ibmcom/informix-developer-database
    #
    #
    # For version information look at running image
    #   $ cat /opt/ibm/informix/ids.properties
    image: ibmcom/informix-developer-database
    container_name: informix
    hostname: informix
    ports:
      - "9088:9088" # JDBC port
    environment:
      LICENSE: accept
      TYPE: oltp
      #DBSERVERNAME: db_ifx1
      DB_USER: informix
      DB_NAME: informix
      DB_PASS: in4mix
      # DB_INIT: 1
      BASEDIR: /opt/ibm
      # sets Informix dir which is /opt/ibm/informix/
      INFORMIXDIR: /opt/ibm/informix
      INFORMIXSERVER: informix
      # INFORMIXSQLHOSTS: /opt/ibm/informix/etc/sqlhosts
      PATH: $PATH:/opt/ibm/informix/bin
    volumes:
      # This will mount current dir data/informix to docker-entrypoint-initdb.d
      - ./data.scripts/informix:/docker-entrypoint-initdb.d/
    command: [ "cdc_update.sh" ]
  #
  # Postgres DB
  postgres:
    # *-----------------------------*
    # To connect to the DB:
    #   docker-compose exec postgres bash -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
    # *-----------------------------*
    image: postgres:16.4
    container_name: postgres
    hostname: postgres
    restart: always
    environment:
      # POSTGRES_DB: test_db
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: public
    volumes:
      - ./data.scripts/postgres:/docker-entrypoint-initdb.d/
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 1s
      timeout: 5s
      retries: 10
    ports:
      - "5432:5432"
  # MySQL
  mysql:
    image: quay.io/debezium/example-mysql:${DEBEZIUM_VERSION}
    container_name: mysql
    hostname: mysql
    ports:
      - 3306:3306
    environment:
      - MYSQL_ROOT_PASSWORD=debezium
      - MYSQL_USER=mysqluser
      - MYSQL_PASSWORD=mysqlpw
  zookeeper:
    image: quay.io/debezium/zookeeper:${DEBEZIUM_VERSION}
    container_name: zookeeper
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
  kafka:
    image: quay.io/debezium/kafka:${DEBEZIUM_VERSION}
    hostname: kafka
    container_name: kafka
    ports:
      - "9092:9092"
    depends_on:
      - zookeeper
    environment:
      - ZOOKEEPER_CONNECT=zookeeper:2181
      - KAFKA_CONFLUENT_SCHEMA_REGISTRY_URL=http://schema-registry:8081
      # NOTE: Kafka will drop messages with self signed certificates. There is a work around but it did not work.
      # Original with SSL
      #- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=BROKER:PLAINTEXT,SSL:SSL,CONTROLLER:PLAINTEXT
      - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=BROKER:PLAINTEXT,CONTROLLER:PLAINTEXT,PLAIN:PLAINTEXT
      # Original with SSL
      #- KAFKA_LISTENERS=BROKER://0.0.0.0:9093,SSL://0.0.0.0:9092,CONTROLLER://0.0.0.0:9094
      - KAFKA_LISTENERS=BROKER://0.0.0.0:9093,PLAIN://0.0.0.0:9092,CONTROLLER://0.0.0.0:9094
      # Original with SSL
      #- KAFKA_ADVERTISED_LISTENERS=SSL://localhost:9092,BROKER://localhost:9093
      - KAFKA_ADVERTISED_LISTENERS=PLAIN://localhost:9092,BROKER://localhost:9093
      #- KAFKA_SSL_CLIENT_AUTH=required
      #- KAFKA_SSL_KEYSTORE_LOCATION=/opt/config/ssl/kafka-ssl-keystore.p12
      #- KAFKA_SSL_KEYSTORE_PASSWORD=top-secret
      #- KAFKA_SSL_KEYSTORE_TYPE=PKCS12
      #- KAFKA_SSL_TRUSTSTORE_LOCATION=/opt/config/ssl/kafka-ssl-truststore.p12
      #- KAFKA_SSL_TRUSTSTORE_PASSWORD=top-secret
      - KAFKA_INTER_BROKER_LISTENER_NAME=BROKER
    volumes:
      - ./resources:/opt/config/ssl:z
#  postgres:
#    image: quay.io/debezium/example-postgres:${DEBEZIUM_VERSION}
#    ports:
#      - "5432:5432"
#    environment:
#     - POSTGRES_USER=postgres
#      - POSTGRES_PASSWORD=postgres
  connect:
    image: quay.io/debezium/connect:${DEBEZIUM_VERSION}
    container_name: connect
    #hostname: connect
    ports:
      - "8083:8083"
    environment:
      # use host localhost if network_mode: host is set
      - CONNECT_BOOTSTRAP_SERVERS=localhost:9092
      - BOOTSTRAP_SERVERS=localhost:9092
      - GROUP_ID=1
      - CONFIG_STORAGE_TOPIC=my_connect_configs
      - OFFSET_STORAGE_TOPIC=my_connect_offsets
      - STATUS_STORAGE_TOPIC=my_connect_statuses
      - CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL=http://schema-registry:8081
      # Will set plugin path in properties file
      - CONNECT_PLUGIN_PATH=/kafka/connect,/kafka/connect/custom-plugins
      - CLASSPATH=.:/kafka/connect:/kafka/connect/custom-plugins
      #- CONNECT_SECURITY_PROTOCOL=SSL
      #- CONNECT_SSL_KEYSTORE_LOCATION=/opt/config/ssl/kafka-ssl-keystore.p12
      #- CONNECT_SSL_KEYSTORE_PASSWORD=top-secret
      #- CONNECT_SSL_KEYSTORE_TYPE=PKCS12
      #- CONNECT_SSL_KEY_PASSWORD=top-secret
      #- CONNECT_SSL_TRUSTSTORE_LOCATION=/opt/config/ssl/kafka-ssl-truststore.p12
      #- CONNECT_SSL_TRUSTSTORE_PASSWORD=top-secret
      #- CONNECT_SSL_TRUSTSTORE_TYPE=PKCS12
      #- CONNECT_PRODUCER_SECURITY_PROTOCOL=SSL
      #- CONNECT_PRODUCER_SSL_KEYSTORE_LOCATION=/opt/config/ssl/kafka-ssl-keystore.p12
      #- CONNECT_PRODUCER_SSL_KEYSTORE_PASSWORD=top-secret
      #- CONNECT_PRODUCER_SSL_KEYSTORE_TYPE=PKCS12
      #- CONNECT_PRODUCER_SSL_KEY_PASSWORD=top-secret
      #- CONNECT_PRODUCER_SSL_TRUSTSTORE_LOCATION=/opt/config/ssl/kafka-ssl-truststore.p12
      #- CONNECT_PRODUCER_SSL_TRUSTSTORE_PASSWORD=top-secret
      #- CONNECT_PRODUCER_SSL_TRUSTSTORE_TYPE=PKCS12
      #- CONNECT_CONSUMER_SECURITY_PROTOCOL=SSL
      #- CONNECT_CONSUMER_SSL_KEYSTORE_LOCATION=/opt/config/ssl/kafka-ssl-keystore.p12
      #- CONNECT_CONSUMER_SSL_KEYSTORE_PASSWORD=top-secret
      #- CONNECT_CONSUMER_SSL_KEYSTORE_TYPE=PKCS12
      #- CONNECT_CONSUMER_SSL_KEY_PASSWORD=top-secret
      #- CONNECT_CONSUMER_SSL_TRUSTSTORE_LOCATION=/opt/config/ssl/kafka-ssl-truststore.p12
      #- CONNECT_CONSUMER_SSL_TRUSTSTORE_PASSWORD=top-secret
      #- CONNECT_CONSUMER_SSL_TRUSTSTORE_TYPE=PKCS12
    #command:
    #  - /bin/bash
    #  - -c
    #  - |
    #    # JDBC Drivers
    #    # ------------
    #    # Informix JDBC Driver
    #    cd /kafka/connect/debezium-connector-informix
    #    curl https://repo1.maven.org/maven2/com/ibm/informix/jdbc/4.50.8/jdbc-4.50.8.jar --compressed --output informix-jdbc-4.50.3.jar
    #    # CLASSPATH
    #    #export CLASSPATH=".:/usr/share/confluent-hub-components/confluentinc-kafka-connect-datagen/lib/:/usr/share/confluent-hub-components/confluentinc-kafka-connect-jdbc/lib/:/home/appuser/plugins/:$CLASSPATH"
    #    #export plugin.path=/usr/local/share/kafka/plugins
        #
    #    sleep infinity
    network_mode: host
    #network_mode: bridge
    volumes:
      - ./resources:/opt/config/ssl:z
      - ./bin/informix-jdbc-4.50.3.jar:/kafka/connect/debezium-connector-informix/informix-jdbc-4.50.3.jar
      - ./bin/ifx-changestream-client-1.1.3.jar:/kafka/connect/debezium-connector-informix/ifx-changestream-client-1.1.3.jar
      # Mount your connector plugins here if they are not included in the image
      - ./custom-plugins:/kafka/connect/custom-plugins
    depends_on:
      - kafka
      - postgres
  #
  # Second Kafka Connect Confluent
  #

  #
  # Schema Registry
  #
  #
  # Schema Registry:
  # URL: https://hub.docker.com/r/confluentinc/cp-schema-registry
  # initial version used: 7.2.1
  # latest: 7.9.1
  #
  #
  schema-registry:
    image: confluentinc/cp-schema-registry:7.9.1
    hostname: schema-registry
    container_name: schema-registry
    depends_on:
      - kafka
    ports:
      - "8081:8081"
    environment:
      SCHEMA_REGISTRY_HOST_NAME: schema-registry
      SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'broker:9092'
      SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
  # UI
  #
  # Kafka Connect UI
  kafka-connect-ui:
    image: landoop/kafka-connect-ui
    container_name: kafka-connect-ui
    environment:
      CONNECT_URL: "http://connect:8083" # Pointing to the Kafka Connect REST API
    ports:
      - "9001:8000"
    depends_on:
      - kafka
      - connect
      - schema-registry
    network_mode: bridge
    extra_hosts:
      - "connect:host-gateway"
  #
  # Kafka UI
  kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:latest
    #image: ashish1981/kafka-ui:latest
    ports:
      - "9004:8080"
    depends_on:
      - kafka
      - connect
      - schema-registry
    environment:
      #KAFKA_CLUSTERS_0_NAME: local
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "broker:9092"
      # JMX port
      KAFKA_CLUSTERS_0_METRICS_PORT: "9101"
      KAFKA_CLUSTERS_0_SCHEMAREGISTRY: "http://schema-registry:8081"
      KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: connect
      KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: "http://connect:8083"
      DYNAMIC_CONFIG_ENABLED: 'true'
  #
  # kafbat-UI
  #
  #kafbat-ui:
  #  container_name: kafbat-ui
  #  image: ghcr.io/kafbat/kafka-ui:latest
  #  ports:
  #    - 9005:8080
  #  environment:
  #    DYNAMIC_CONFIG_ENABLED: 'true'
  #  volumes:
  #    - ./ui/kafka-ui.yml:/etc/kafkaui/dynamic_config.yaml
  #kafbat-ui:
  #  container_name: kafbat-ui
  #  hostname: kafbat-ui
  #  image: ghcr.io/kafbat/kafka-ui:latest
  #  ports:
  #    - 9005:8080
  #  environment:
  #    DYNAMIC_CONFIG_ENABLED: 'true'
  #    KAFKA_CLUSTERS_0_NAME: local
      # other properties, omitted
      #SPRING_CONFIG_ADDITIONAL-LOCATION: /tmp/config.yml
  #  volumes:
  #    - ./ui/kafka-ui.yml:/tmp/config.yml
  #  depends_on:
  #    - kafka
  #    - schema-registry
  #
  #