Building and deploying everything to Docker locally

There are multiple ways in which we can use the Docker Compose files based on our needs.

In general, when we are developing the application, we can run the application with the Maven or Gradle command so that we can debug the application and reload the changes faster, as well as start the database and JHipster registry with Docker.

Otherwise, you can start the entire application from the app.yml file, which will kickstart the database, JHipster Registry, and then the application itself. To do that, open your Terminal or Command Prompt, go to each of the application folders, and run the following commands.

First, Dockerize the application by taking a production build of our application with the following command:

> ./gradlew bootJar -Pprod jibDockerBuild

Once done, we can start the app via the docker-compose command:

> docker-compose -f src/main/docker/app.yml up -d

-f specifies the file that docker-compose should start the containers with. The -d flag tells docker-compose to run everything in detached mode. This will start the application in Docker and expose the application on ports 8080, 8081, and 8082, the registry server on port 8761, and the database on ports 3306, 3307, and 27017.

Once you have done this for all three applications, we can check the running Docker containers with the following command:

> docker ps -a

It should list all seven containers:

As you can see, there are three app containers (store, notification, and invoice), as well as a JHipster Registry, followed by three database containers (two MySQL and one MongoDB. Their order may vary).

You can view the logs from the containers by running docker logs <container id>. You will see the application running on http://localhost:8080, and the registry running on http://localhost:8761.

You can shut down these instances by running docker-compose -f src/main/docker/app.yml down on each of the application folders or by running docker kill <container id> for each of the preceding containers.

Now, let's learn how we can do the same with the docker-compose sub-generator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.119.17