You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images/dockerfiles.adoc
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -33,18 +33,30 @@ Here is an example of a Dockerfile using `jarmode`.
33
33
34
34
[source,dockerfile]
35
35
----
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
37
38
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
38
41
ARG JAR_FILE=target/*.jar
42
+
# Copy the jar file to the working directory and rename it to application.jar
39
43
COPY ${JAR_FILE} application.jar
44
+
# Extract the jar file using an efficient layout
40
45
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
41
46
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
43
49
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
0 commit comments