-
Notifications
You must be signed in to change notification settings - Fork 40.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docker without buildpacks documentation
Explain how CDS can be enabled with plain Dockerfiles. Closes gh-42106
- Loading branch information
1 parent
599f1f1
commit 8d44fd5
Showing
3 changed files
with
54 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/partials/dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Perform the extraction in a separate builder container | ||
FROM bellsoft/liberica-openjre-debian:17-cds AS builder | ||
WORKDIR /builder | ||
# This points to the built jar file in the target folder | ||
# Adjust this to 'build/libs/*.jar' if you're using Gradle | ||
ARG JAR_FILE=target/*.jar | ||
# Copy the jar file to the working directory and rename it to application.jar | ||
COPY ${JAR_FILE} application.jar | ||
# Extract the jar file using an efficient layout | ||
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted | ||
|
||
# This is the runtime container | ||
FROM bellsoft/liberica-openjre-debian:17-cds | ||
WORKDIR /application | ||
# Copy the extracted jar contents from the builder container into the working directory in the runtime container | ||
# Every copy step creates a new docker layer | ||
# This allows docker to only pull the changes it really needs | ||
COPY --from=builder /builder/extracted/dependencies/ ./ | ||
COPY --from=builder /builder/extracted/spring-boot-loader/ ./ | ||
COPY --from=builder /builder/extracted/snapshot-dependencies/ ./ | ||
COPY --from=builder /builder/extracted/application/ ./ |