Skip to content

Commit 0c3aa52

Browse files
Add How-To Guide for building images with CDS and buildpacks
Closes gh-40762
1 parent 2df0c79 commit 0c3aa52

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[[howto.class-data-sharing]]
2+
= Class Data Sharing
3+
4+
This section includes information about using Class Data Sharing (CDS) with Spring Boot applications.
5+
For an overview of Spring Boot support for CDS, see xref:reference:packaging/class-data-sharing.adoc[Class Data Sharing].
6+
7+
8+
[[howto.class-data-sharing.buildpacks]]
9+
== Packaging an Application Using CDS and Buildpacks
10+
11+
Spring Boot's xref:reference:packaging/container-images/cloud-native-buildpacks.adoc[support for Cloud Native Buildpacks] along with the https://paketo.io/docs/reference/java-reference[Paketo Java buildpack] and its https://paketo.io/docs/reference/java-reference/#spring-boot-applications[Spring Boot support] can be used to generate a Docker image containing a CDS-optimized application.
12+
13+
To enable CDS optimization in a generated Docker image, the buildpack environment variable `BP_JVM_CDS_ENABLED` should be set to `true` when building the image as described in the xref:maven-plugin:build-image.adoc#build-image.examples.builder-configuration[Maven plugin] and xref:gradle-plugin:packaging-oci-image.adoc#build-image.examples.builder-configuration[Gradle plugin] documentation.
14+
This will cause the buildpack to do a training run of the application, save the CDS archive in the image, and use the CDS archive when launching the application.
15+
16+
The buildpack environment variable `BP_SPRING_AOT_ENABLED` can also be set to `true` to enable AOT mode along with CDS when running an application that has been xref:reference:packaging/aot.adoc[built with Ahead-of-Time processed].
17+
18+
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.
19+
20+

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/partials/nav-how-to.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
** xref:how-to:native-image/index.adoc[]
2222
*** xref:how-to:native-image/developing-your-first-application.adoc[]
2323
*** xref:how-to:native-image/testing-native-applications.adoc[]
24+
** xref:how-to:class-data-sharing.adoc[]
2425
** xref:how-to:deployment/index.adoc[]
2526
*** xref:how-to:deployment/traditional-deployment.adoc[]
2627
*** xref:how-to:deployment/cloud.adoc[]

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Class Data Sharing (CDS) is a https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[JVM feature] that can help reduce the startup time and memory footprint of Java applications.
55

6-
To use it, you should first perform a training run on your application in exploded form:
6+
To use it, you should first perform a training run on your application in extracted form:
77

88
[source,shell]
99
----

0 commit comments

Comments
 (0)