Running the Application in Docker

Learn how to run different parts of the application locally with Docker.

In previous chapters, we covered how to run the backend Spring Boot application and how to run the frontend with Angular from the command line. However, it’s much easier to run everything together in Docker containers. Let’s look at how to set up and locally run the application this way.

These instructions are for locally running the application with Docker.

Generate the build artifacts

We’ll create Docker images from the build artifacts. First, we need to make sure we generate the jar file for the Spring Boot application. Also, we must generate HTML and JavaScript artifacts from the Angular code.

To build the backend, you need to execute the following command from the spring-boot-reactive-web folder:

$ mvnw clean package

Then, we can find the resulting .jar file in the target folder.

To build the frontend code, run this command from the angular-reactive folder:

$ npm run ng build

In this case, the HTML and JavaScript output will be placed into the dist folder.

What we’ll do with Docker is build both the backend and the frontend and deploy the resulting artifacts as containers. We’ll also add a MongoDB image with a custom configuration.

Get hands-on with 1400+ tech skills courses.