Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Gradle to build a Docker image of Spring-Boot

Shulou Source: shulou.com Published: 2022-06-01 06:54:57 11月16日 Update

In this issue, the editor will bring you a Docker image of how to use Gradle to build Spring-Boot. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Usually we use Dockerfile to build the Docker image of the project, but there are also requirements that we want to use gralde to build and upload the image when compiling the project, so this tutorial explains the process of using gradle to write a configuration Dockerfile and generate an image.

1. Add dependency

The tutorial uses the gradle-docker plug-in to configure the build image function of dockerfile in the script of Gradle.

The gradle-docker plug-in is already included in jCenter and MavenCentral. So you just need to add dependencies in dependencies to use the docker plug-in.

The configuration in build.gradle is as follows, and other configurations are omitted:

two。 Application plug-in

Add the following code to build.gradle

3. Create a Dockerfile file with the following contents:

4. Add task Task

5. Compile and build the Docker image of the Spring-Boot project

Execute command in the console:. / gradlew clean build dockerBuilder-- info

Waiting for BUILD SUCCESSFUL to appear proves that the compilation is successful.

Using the docker images command, you can see that a newly generated image named my-groupcom.meatball/mini-dolphin-eureka-server,tag is 0.0.1-DEV.

The above is the editor for you to share how to use Gradle to build Spring-Boot Docker image, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Images plug-ins configuration content project compilation commands tutorials analysis success professional small and medium code tasks rich content functions that is console files articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei macOS Redmi Apple