3.2 Docker Environment

Setting up your local docker environment for this lab.

Changes to the docker-compose file

To split the monolith in two microservices we need to change our docker-compose.yaml file.

Monolith Split

Microservice container specification

First we deleted the application and application-db specification which belonged to our monolith. Then we created a specification for the two microservices order and stock.

As we are building the order service by ourselves we reference a local container image. The stock service uses a pre-built image from the quay.io/acend registry.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  order:
    image: microservices-lab-rest-order:latest
    hostname: order
    container_name: rest-order
    ports:
      - 8080:8080
    networks:
      - rest
    depends_on:
      - order-db
    environment:
      - QUARKUS_HTTP_PORT=8080
      - QUARKUS_DATASOURCE_JDBC_URL=jdbc:tracing:postgresql://order-db:5432/admin
      - APPLICATION_ARTICLESTOCK_API_URL=http://stock:8080/

  stock:
    image: quay.io/acend/microservices-lab-rest-stock:latest
    hostname: stock
    container_name: rest-stock
    ports:
      - 8081:8080
    networks:
      - rest
    depends_on:
      - stock-db
    environment:
      - QUARKUS_HTTP_PORT=8080
      - QUARKUS_DATASOURCE_JDBC_URL=jdbc:tracing:postgresql://stock-db:5432/admin

As both microservices need their own postgres database we added two databases to our docker-compose.yaml.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  order-db:
    image: docker.io/postgres:13
    hostname: order-db
    container_name: rest-order-db
    volumes:
      - order-db-data:/var/lib/postgresql/data/
    networks:
      - rest
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=1234
    ports:
      - 5432:5432

  stock-db:
    image: docker.io/postgres:13
    hostname: stock-db
    container_name: rest-stock-db
    volumes:
      - stock-db-data:/var/lib/postgresql/data/
    networks:
      - rest
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=1234
    ports:
      - 5433:5432

Task 3.2.1 - Inspecting the docker environment

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

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