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/how-to/pages/class-data-sharing.adoc
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,12 @@ This will cause the buildpack to do a training run of the application, save the
15
15
16
16
The Paketo Buildpack for Spring Boot https://github.com/paketo-buildpacks/spring-boot?tab=readme-ov-file#configuration[documentation] has information on other configuration options that can be enabled with builder environment variables, like `CDS_TRAINING_JAVA_TOOL_OPTIONS` that allows to override the default `JAVA_TOOL_OPTIONS`, only for the CDS training run.
17
17
18
+
[[howto.class-data-sharing.dockerfiles]]
19
+
== Packaging an Application Using CDS and Dockerfiles
20
+
21
+
If you don't want to use Cloud Native Buildpacks, it is also possible to use CDS with a `Dockerfile`.
22
+
For more information about that, please see the xref:reference:packaging/container-images/dockerfiles.adoc#packaging.container-images.dockerfiles.cds[Dockerfiles reference documentation].
While it is possible to convert a Spring Boot uber jar into a Docker image with just a few lines in the Dockerfile, using the xref:packaging/container-images/efficient-images.adoc#packaging.container-images.efficient-images.layering[layering feature] will result in an optimized image.
4
+
While it is possible to convert a Spring Boot uber jar into a Docker image with just a few lines in the `Dockerfile`, using the xref:packaging/container-images/efficient-images.adoc#packaging.container-images.efficient-images.layering[layering feature] will result in an optimized image.
5
5
When you create a jar containing the layers index file, the `spring-boot-jarmode-tools` jar will be added as a dependency to your jar.
6
6
With this jar on the classpath, you can launch your application in a special mode which allows the bootstrap code to run something entirely different from your application, for example, something that extracts the layers.
7
7
@@ -28,32 +28,12 @@ Available commands:
28
28
help Help about any command
29
29
----
30
30
31
-
The `extract` command can be used to easily split the application into layers to be added to the Dockerfile.
32
-
Here is an example of a Dockerfile using `jarmode`.
31
+
The `extract` command can be used to easily split the application into layers to be added to the `Dockerfile`.
32
+
Here is an example of a `Dockerfile` using `jarmode`.
33
33
34
34
[source,dockerfile]
35
35
----
36
-
# Perform the extraction in a separate builder container
37
-
FROM bellsoft/liberica-openjre-debian:17-cds AS builder
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
41
-
ARG JAR_FILE=target/*.jar
42
-
# Copy the jar file to the working directory and rename it to application.jar
43
-
COPY ${JAR_FILE} application.jar
44
-
# Extract the jar file using an efficient layout
45
-
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
46
-
47
-
# This is the runtime container
48
-
FROM bellsoft/liberica-openjre-debian:17-cds
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