17 Ekim 2021 Pazar

spring-boot-gradle-plugin Fat Jar

bootRun Goal
Örnek
Spring projesini çalıştırmak için şöyle yaparız
./gradlew bootRun
bootBuildImage Goal
Açıklaması şöyle. Yani Dokcer image içinde BellSoft Liberica JDK kullanır
You may build a Docker image by defining a Dockerfile where the various layers of the Docker image need to be defined. The downside of this approach is that creating a Dockerfile needs a good understanding of the Docker technology. To empower the containerization, Cloud Native Buildpacks by Pivotal transform your source code into an OCI (Open Container Initiative) compatible Docker image without the need of a Dockerfile. The container image can then be deployed in any modern cloud.

Paketo.io is a Cloud Foundry project and one of the most popular implementations of Cloud Native Buildpacks. It can transform the source code of major programming languages into a container image.

Spring Boot natively supports the buildpacks that create an image with BellSoft Liberica JDK. It also looks at the build.gradle file and the Spring configuration file to build the Docker image.
Örnek
Şöyle yaparız
> sudo ./gradlew bootBuildImage
Çıktısı şöyle
> Task :bootBuildImage 
Building image 'docker.io/library/microservice-customer:1.0.0'   
> Pulling builder image 'docker.io/paketobuildpacks/builder:base' ..................................................  
> Pulled builder image 'paketobuildpacks/builder@sha256:35e29183d1aec1b4d79ebec4fb47ef309dc4e803e2706b5a7336d8ebe68053e8'  
> Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' ..................................................  
> Pulled run image 'paketobuildpacks/run@sha256:d968d1e9827704283bdfd678d9cb2b85d6e0bd826b0cb1f14bbceb5bb6e0f571'  
> Executing lifecycle version v0.10.2  
> Using build cache volume 'pack-cache-9d89fc6213b6.build'   
> Running creator
.
.
.
Açıklaması şöyle
If you look at the output, it is evident that in the first step, it runs the Paketo BellSoft Liberica Buildpack 7.0.0, which in turn downloads the BellSoft Liberica JDK and JRE implementations for the JVM (version 11, as defined in the build.gradle file) from GitHub.

Thus it provides BellSoft Liberica JRE 11.0.10 as the JVM runtime layer of the Docker image.

Next the command runs Paketo Spring Boot Buildpack 4.0.0. It creates the layers for the application, dependencies, and the spring-boot-loader module.

Finally, it creates a Docker image. For our demo, the Customer microservice container image looks as such: docker.io/library/microservice-customer:1.0.0

Then we create one for the Order microservice going through the similar step: docker.io/library/microservice-order:1.0.0

Örnek
Şöyle yaparız
./gradlew bootBuildImage --imageName=splitdemo/spring-boot-docker

Hiç yorum yok:

Yorum Gönder