Skip to content

Commit c34c0d1

Browse files
committed
Merge branch '3.3.x'
2 parents b606bbb + fe55ce9 commit c34c0d1

File tree

1 file changed

+14
-2
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images

1 file changed

+14
-2
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images/dockerfiles.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,30 @@ Here is an example of a Dockerfile using `jarmode`.
3333

3434
[source,dockerfile]
3535
----
36-
FROM bellsoft/liberica-runtime-container:jre-17-cds-slim-glibc as builder
36+
# Perform the extraction in a separate builder container
37+
FROM bellsoft/liberica-openjre-debian:17-cds AS builder
3738
WORKDIR /builder
39+
# This points to the built jar file in the target folder
40+
# Adjust this to 'build/libs/*.jar' if you're using Gradle
3841
ARG JAR_FILE=target/*.jar
42+
# Copy the jar file to the working directory and rename it to application.jar
3943
COPY ${JAR_FILE} application.jar
44+
# Extract the jar file using an efficient layout
4045
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
4146
42-
FROM bellsoft/liberica-runtime-container:jre-17-cds-slim-glibc
47+
# This is the runtime container
48+
FROM bellsoft/liberica-openjre-debian:17-cds
4349
WORKDIR /application
50+
# Copy the extracted jar contents from the builder container into the working directory in the runtime container
51+
# Every copy step creates a new docker layer
52+
# This allows docker to only pull the changes it really needs
4453
COPY --from=builder /builder/extracted/dependencies/ ./
4554
COPY --from=builder /builder/extracted/spring-boot-loader/ ./
4655
COPY --from=builder /builder/extracted/snapshot-dependencies/ ./
4756
COPY --from=builder /builder/extracted/application/ ./
57+
# Start the application jar - this is not the uber jar used by the builder
58+
# This jar only contains application code and references to the extracted jar files
59+
# This layout is efficient to start up and CDS friendly
4860
ENTRYPOINT ["java", "-jar", "application.jar"]
4961
----
5062

0 commit comments

Comments
 (0)