4.2 Docker Environment

Setting up your local docker environment for this lab.

Changes to the docker-compose file

Since we are going to use Apache Kafka as a message broker, there are some changes to our docker-compose.yaml file.

Apache Kafka Broker

To use Apache Kafka the following was added to our docker-compose.yaml file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

  zookeeper:
    image: quay.io/debezium/zookeeper:2.3
    hostname: zookeeper
    container_name: debezium-zookeeper
    networks:
      - kafka
    ports:
      - 2181:2181
      - 2888:2888
      - 3888:3888

  kafka:
    image: quay.io/acend/microservices-lab-debezium-kafka:latest
    hostname: kafka
    container_name: debezium-kafka
    ports:
      - 9092:9092
    networks:
      - kafka
    depends_on:
      - zookeeper
    environment:
      - ZOOKEEPER_CONNECT=zookeeper:2181

Kafka Viewer

Further a simple kafka-viewer microservice was added to the docker-compose.yaml. The kafka-viewer is a small web-UI which displays messages passing through our kafka topics.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  viewer:
    image: quay.io/acend/microservices-lab-kafka-viewer:latest
    ports:
      - 8082:8080
    networks:
      - kafka
    depends_on:
      - kafka
    environment:
      - QUARKUS_HTTP_PORT=8080
      - MP_MESSAGING_INCOMING_KAFKAMESSAGES_TOPICS=shop-order-request,shop-order-confirmation,shop-order-compensation
      - MP_MESSAGING_INCOMING_KAFKAMESSAGES_KEY_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer
      - MP_MESSAGING_INCOMING_KAFKAMESSAGES_VALUE_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer

Microservice Configuration

To ensure your microservices will connect to the Kafka broker an additional property has been added to both microservices. The property KAFKA_BOOTSTRAP_SERVERS=kafka:9092 in the environment section will ensure that the microservices will connect to our kafka message broker.

Task 4.2.1 - Inspecting the docker environment

Have a look at the /code/kafka/docker folder and get familiar with the docker environment specified in docker-compose.yaml.

Last modified February 12, 2024: fix debezium lab version (9e6013e)