Skip to content

Run the application with Docker Compose

EdwinVW edited this page Oct 12, 2022 · 1 revision

This will describe how to run the Pitstop solution using Docker-Compose.

Execute the following steps to start the application:

  • Make sure your have satisfied the Prerequisites and you have built all the Docker images as described in Building the Docker images. You can also pull the images from the Pitstop repo available in Docker Hub.

  • Open up a Powershell window and go to the Pitstop/src folder.

  • Issue the following command:

    docker-compose up
    

    This will start the solution with a single instance of the API services.

Next steps:

  • Follow the steps described in Testing the application to test the application functionality.
  • See Logging to learn how to get to the application logging.
  • In the logging you might see some errors during start-up. See Resiliency to learn where these errors are coming from.

Optional steps

The steps described below are optional steps to test different aspects of the application.

Scaling the services

If you want to start the solution with multiple instances of the API services running, use the following command:

docker-compose up -d --scale customermanagementapi=2 --scale vehiclemanagementapi=2 --scale workshopmanagementapi=3

This uses the scale argument to specify the number of instances of each services that must be started. The docker-compose networking stack will automatically load-balance the requests over the available instances. From the client perspective nothing needs to change. It can still communicate with a service by using the container-name specified in the docker-compose.yml file (e.g. workshopmanagementapi) as if there was only 1 instance. But when you look at the started containers, you will see multiple instances running with a name that is postfixed with a number (e.g. workshopmanagementapi_1, workshopmanagementapi_2).

Running with APIs exposed on localhost

In order to make sure the APIs are reachable from localhost, start the solution using the docker-compose.local.yml override file. You do this by starting the solution using the following command: docker-compose -f docker-compose.yml -f docker-compose.local.yml up. This will make sure that the ports used by the API services are exposed to the host so you can access them directly from the browser.

You can also use the StartSolutionWithLocalAPIs.ps1 / StartSolutionWithLocalAPIs.sh scripts to start the solution.

Now you can access the individual APIs in the system. You can use the test UIs that are auto-generated by Swashbuckle.

The following URLs can be used:

API URL
CustomerManagement http://localhost:5100/swagger
VehicleManagement http://localhost:5000/swagger
WorkshopManagement http://localhost:5200/swagger

This way of running the application is only possible if you run 1 instance of each service. If you run more than one instance, this will result in an error because multiple instances would be exposed on the same port on localhost.