Now that we set up HTTPS, we can build the container using the following commands:
docker compose build
We can execute the following command to start the containers:
docker compose up
This should start the containers and feed you an aggregated log with a color per service. The beginning of the log trail should look like this:
[+] Running 3/0
✔ Container c19-repr.products-1 Created 0.0s
✔ Container c19-repr.baskets-1 Created 0.0s
✔ Container c19-repr.bff-1 Created 0.0s
Attaching to c19-repr.baskets-1, c19-repr.bff-1, c19-repr.products-1
c19-repr.baskets-1 | info: Microsoft.Hosting.Lifetime[14]
c19-repr.baskets-1 | Now listening on: http://[::]:80
c19-repr.baskets-1 | info: Microsoft.Hosting.Lifetime[14]
c19-repr.baskets-1 | Now listening on: https://[::]:443
…
To stop the services, press Ctrl+C. When you want to destroy the running application, enter the following command:
docker compose down
Now, with docker compose up, our services should be running. To make sure, let’s try them out.
Briefly testing the services
The project contains the following services, each containing an http file you can leverage to query the services using Visual Studio or in VS Code using an extension:
Service | HTTP file | Host |
REPR.Baskets | REPR.Baskets.http | https://localhost:60280 |
REPR.BFF | REPR.BFF.http | https://localhost:7254 |
REPR.Products | REPR.Products.http | https://localhost:57362 |
Table 19.3: each service, HTTP file, and HTTPS hostname and port.
We can leverage the HTTP requests from each directory to test the API. I suggest starting by trying the low-level APIs, then the BFF, so you know if something is wrong with them directly instead of wondering what is wrong with the BFF (which calls the low-level APIs).
I use the REST Client extension in VS Code (https://adpg.link/UCGv) and the built-in support in Visual Studio 2022 version 17.6 or later.
Here’s a part of the REPR.Baskets.http file:
@Web_HostAddress = https://localhost:60280
@ProductId = 3
@CustomerId = 1
GET {{Web_HostAddress}}/baskets/{{CustomerId}}
###
POST {{Web_HostAddress}}/baskets
Content-Type: application/json
{
“customerId”: {{CustomerId}},
“productId”: {{ProductId}},
“quantity”: 10
}
…
The highlighted lines are variables that the requests reuse. The ### characters act as a separator between requests. In VS or VS Code, you should see a Send request button on top of each request. Executing the POST request, then the GET should output the following:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
[
{
“productId”: 3,
“quantity”: 10
}
]
If you can reach one endpoint, this means the service is running. Nonetheless, feel free to play with the requests, modify them, and add more.
I did not move the tests over from Chapter 18. Automating the validation of our deployment could be a good exercise for you to test your testing skills.
After you validate that the three services are running, we can continue and look at how the BFF communicates with the Baskets and Products services.