Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Buildpacks CDS and Spring AOT support #40762

Open
sdeleuze opened this issue May 14, 2024 · 2 comments
Open

Document Buildpacks CDS and Spring AOT support #40762

sdeleuze opened this issue May 14, 2024 · 2 comments
Labels
for: team-meeting An issue we'd like to discuss as a team to make progress type: documentation A documentation update
Milestone

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented May 14, 2024

As discussed with @philwebb today, it would be nice if Spring Boot 3.3 documentation could make CDS and Spring AOT Buildpacks support, which has just been deployed to production, more discoverable. The various configurations are now documented in https://github.com/paketo-buildpacks/spring-boot README, but from a Spring Boot POV my proposal would be to:

  • Document that (at least) in the efficient deployment section
  • Link the official CDS documentation
  • Mention that CDS can be enabled via BP_JVM_CDS_ENABLED=true. In practice, that means Buildpacks will perform a training run, create a related .jsa file with the application classes cached, and use it by default when running the container.
  • Document that CDS_TRAINING_JAVA_TOOL_OPTIONS can be used to fine tune the training run configuration (typical use case is to avoid early DB interactions, related documentation will be available in https://github.com/spring-projects/spring-lifecycle-smoke-tests, I plan to work on that).
  • Mention that Spring AOT can also be enabled via BP_SPRING_AOT_ENABLED=true. That requires AOT processing upfront (already documented) and will enable the AOT mode when running the container.
  • Link https://github.com/paketo-buildpacks/spring-boot for more details (especially about the BPL* configs we don't have to document on Spring Boot side).

If you do tests to ensure it works as expected, be aware that for now it is expected to work only on x86. aarch64 support should be fixed (when leveraging the beta multi arch support) before Spring Boot 3.3.0 release (ongoing related work is happening).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 14, 2024
@anthonydahanne
Copy link
Contributor

just a (arm64) note : spring-boot Maven and Gradle plugins use, by default,

  • the builders named paketobuildpacks/builder-jammy-base:latest or paketobuildpacks/builder-jammy-tiny:latest when native is activated - none of them support dual arch (yet) ❌
  • the (composite )buildpacks named paketobuildpacks/java:latest or, when native is enabled, paketobuildpacks/java-native-image:latest both of them are published as dual arch now ✅

To benefit from dual arch support, the users have to specify an alternative builder: paketobuildpacks/builder-jammy-buildpackless-tiny:latest which is dual arch - otherwise, the arm64 path is not complete and won't allow users to use Java buildpacks arm64 flavor.

Since this builder is buildpackless users have to manually specify the buildpacks they need.

Maven:

<plugin>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
	<executions> <!-- not necessary for arm64, but better take good habits now-->
		<execution> 
			<id>process-aot</id>
			<goals>
				<goal>process-aot</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<image>
			<env> <!-- not necessary for arm64, but better take good habits now-->
				<BP_JVM_CDS_ENABLED>true</BP_JVM_CDS_ENABLED>
				<BP_SPRING_AOT_ENABLED>true</BP_SPRING_AOT_ENABLED>
			</env>
			<buildpacks>
				<buildpack>paketobuildpacks/java</buildpack>
			</buildpacks>
			<builder>paketobuildpacks/builder-jammy-buildpackless-tiny</builder>
		</image>
	</configuration>
</plugin>

Gradle:

plugins {
[...]
	id("org.graalvm.buildtools.native") version "0.10.1" // not necessary for arm64, but better take good habits now
}
[...]
tasks.bootBuildImage {
	builder.set("paketobuildpacks/builder-jammy-buildpackless-tiny")
	buildpacks.add("gcr.io/paketo-buildpacks/java")
	environment.put("BP_SPRING_AOT_ENABLED","true") // not necessary for arm64, but better take good habits now
	environment.put("BP_JVM_CDS_ENABLED","true") // not necessary for arm64, but better take good habits now
}

There is no scheduled date when the default builders paketobuildpacks/builder-jammy-base:latest and paketobuildpacks/builder-jammy-tiny:latest will be published as dual arch(the best bet is to wait for the Ubuntu Noble based builders that will all be dual arch from day one and should arrive soon, but not for SB 3.3)

@scottfrederick scottfrederick added for: team-meeting An issue we'd like to discuss as a team to make progress type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels May 14, 2024
@scottfrederick scottfrederick added this to the 3.3.x milestone May 14, 2024
@sdeleuze
Copy link
Contributor Author

sdeleuze commented May 20, 2024

I have began to document the configuration customizations required to avoid early DB interactions cc @christophstrobl:

I am now working on adding CDS automated tests to https://github.com/spring-projects/spring-lifecycle-smoke-tests, so maybe the current CDS documentation can link https://github.com/spring-projects/spring-lifecycle-smoke-tests/blob/main/STATUS.adoc like what is done for CRaC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-meeting An issue we'd like to discuss as a team to make progress type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants