I am aware of two approaches. Below are Dockerfile snippets.

# This approach generates and runs application classes stored in the `extracted_layers/application/BOOT-INF/classes/` folder. 
.
.
.
RUN java -Djarmode=layertools -jar app.jar extract --destination extracted_layers
.
.
.
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-XX:+UseG1GC", "org.springframework.boot.loader.launch.JarLauncher"]
# This approach generates and runs the application jar stored in the `extracted_layers/application/` folder
.
.
.
RUN java -Djarmode=tools -jar app.jar extract --layers --destination extracted_layers
.
.
.
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-XX:+UseG1GC", "-jar", "app.jar"]

Notice the difference in the tool used specified by -Djarmode .

The documentation uses the jar approach: https://docs.spring.io/spring-boot/3.5/reference/packaging/container-images/dockerfiles.html

I would think that using the extracted classes provides a faster startup.

1 Reply 1

I’m using Gradle’s Spring Boot bootBuildImage task (./gradlew bootBuildImage), which builds the container image using Cloud Native Buildpacks.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.