mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Use Paketo tiny builder by default for JVM and native apps
Closes gh-40859
This commit is contained in:
parent
99904d0307
commit
26b59ae912
|
@ -267,7 +267,6 @@ publishing.publications.withType(MavenPublication) {
|
|||
delegate.artifactId('spring-boot-maven-plugin')
|
||||
configuration {
|
||||
image {
|
||||
delegate.builder("paketobuildpacks/builder-jammy-tiny:latest");
|
||||
env {
|
||||
delegate.BP_NATIVE_IMAGE("true")
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -45,7 +45,7 @@ import org.springframework.util.Assert;
|
|||
*/
|
||||
public class BuildRequest {
|
||||
|
||||
static final String DEFAULT_BUILDER_IMAGE_NAME = "paketobuildpacks/builder-jammy-base:latest";
|
||||
static final String DEFAULT_BUILDER_IMAGE_NAME = "paketobuildpacks/builder-jammy-tiny:latest";
|
||||
|
||||
private static final ImageReference DEFAULT_BUILDER = ImageReference.of(DEFAULT_BUILDER_IMAGE_NAME);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ The following table summarizes the available properties and their default values
|
|||
| `builder`
|
||||
| `--builder`
|
||||
| Name of the Builder image to use.
|
||||
| `paketobuildpacks/builder-jammy-base:latest` or `paketobuildpacks/builder-jammy-tiny:latest` when {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin] is applied.
|
||||
| `paketobuildpacks/builder-jammy-tiny:latest`
|
||||
|
||||
| `runImage`
|
||||
| `--runImage`
|
||||
|
@ -237,7 +237,10 @@ Application contents will also be in this location in the generated image.
|
|||
|
||||
NOTE: The plugin detects the target Java compatibility of the project using the JavaPlugin's `targetCompatibility` property.
|
||||
When using the default Paketo builder and buildpacks, the plugin instructs the buildpacks to install the same Java version.
|
||||
You can override this behaviour as shown in the xref:packaging-oci-image.adoc#build-image.examples.builder-configuration[builder configuration] examples.
|
||||
You can override this behavior as shown in the xref:packaging-oci-image.adoc#build-image.examples.builder-configuration[builder configuration] examples.
|
||||
|
||||
NOTE: The default builder `paketobuildpacks/builder-jammy-tiny:latest` does not include a shell.
|
||||
Applications that require a shell to run a start script, as might be the case when the {url-gradle-docs-application-plugin}[`application` plugin] has been applied to generate a distribution zip archive, should override the `builder` configuration to use one that includes a shell, such as `paketobuildpacks/builder-jammy-base:latest` or `paketobuildpacks/builder-jammy-full:latest`.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -89,6 +89,6 @@ When the {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin
|
|||
. Configures the GraalVM extension to disable Toolchain detection.
|
||||
. Configures each GraalVM native binary to require GraalVM 22.3 or later.
|
||||
. Configures the `bootJar` task to include the reachability metadata produced by the `collectReachabilityMetadata` task in its jar.
|
||||
. Configures the `bootBuildImage` task to use `paketobuildpacks/builder-jammy-tiny:latest` as its builder and to set `BP_NATIVE_IMAGE` to `true` in its environment.
|
||||
. Configures the `bootBuildImage` task to set `BP_NATIVE_IMAGE` to `true` in its environment.
|
||||
|
||||
|
||||
|
|
|
@ -105,10 +105,7 @@ class NativeImagePluginAction implements PluginApplicationAction {
|
|||
private void configureBootBuildImageToProduceANativeImage(Project project) {
|
||||
project.getTasks()
|
||||
.named(SpringBootPlugin.BOOT_BUILD_IMAGE_TASK_NAME, BootBuildImage.class)
|
||||
.configure((bootBuildImage) -> {
|
||||
bootBuildImage.getBuilder().convention("paketobuildpacks/builder-jammy-tiny:latest");
|
||||
bootBuildImage.getEnvironment().put("BP_NATIVE_IMAGE", "true");
|
||||
});
|
||||
.configure((bootBuildImage) -> bootBuildImage.getEnvironment().put("BP_NATIVE_IMAGE", "true"));
|
||||
}
|
||||
|
||||
private void configureJarManifestNativeAttribute(Project project) {
|
||||
|
|
|
@ -92,8 +92,7 @@ class NativeImagePluginActionIntegrationTests {
|
|||
void bootBuildImageIsConfiguredToBuildANativeImage() {
|
||||
writeDummySpringApplicationAotProcessorMainClass();
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImageConfiguration");
|
||||
assertThat(result.getOutput()).contains("paketobuildpacks/builder-jammy-tiny")
|
||||
.contains("BP_NATIVE_IMAGE = true");
|
||||
assertThat(result.getOutput()).contains("BP_NATIVE_IMAGE = true");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
|
|
|
@ -173,7 +173,7 @@ class BootBuildImageTests {
|
|||
@Test
|
||||
void whenNoBuilderIsConfiguredThenRequestHasDefaultBuilder() {
|
||||
assertThat(this.buildImage.createRequest().getBuilder().getName())
|
||||
.isEqualTo("paketobuildpacks/builder-jammy-base");
|
||||
.isEqualTo("paketobuildpacks/builder-jammy-tiny");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -7,7 +7,6 @@ apply plugin: 'org.graalvm.buildtools.native'
|
|||
|
||||
task('bootBuildImageConfiguration') {
|
||||
doFirst {
|
||||
println "builder = ${tasks.getByName('bootBuildImage').builder.get()}"
|
||||
println "BP_NATIVE_IMAGE = ${tasks.getByName('bootBuildImage').environment.get()['BP_NATIVE_IMAGE']}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ The following table summarizes the available parameters and their default values
|
|||
| `builder` +
|
||||
(`spring-boot.build-image.builder`)
|
||||
| Name of the Builder image to use.
|
||||
| `paketobuildpacks/builder-jammy-base:latest`
|
||||
| `paketobuildpacks/builder-jammy-tiny:latest`
|
||||
|
||||
| `runImage` +
|
||||
(`spring-boot.build-image.runImage`)
|
||||
|
|
|
@ -69,7 +69,7 @@ class ImageTests {
|
|||
void getBuildRequestWhenNoCustomizationsUsesDefaults() {
|
||||
BuildRequest request = new Image().getBuildRequest(createArtifact(), mockApplicationContent());
|
||||
assertThat(request.getName()).hasToString("docker.io/library/my-app:0.0.1-SNAPSHOT");
|
||||
assertThat(request.getBuilder().toString()).contains("paketobuildpacks/builder-jammy-base");
|
||||
assertThat(request.getBuilder().toString()).contains("paketobuildpacks/builder-jammy-tiny");
|
||||
assertThat(request.getRunImage()).isNull();
|
||||
assertThat(request.getEnv()).isEmpty();
|
||||
assertThat(request.isCleanCache()).isFalse();
|
||||
|
|
|
@ -274,13 +274,9 @@ class PaketoBuilderTests {
|
|||
"paketo-buildpacks/apache-tomcat", "paketo-buildpacks/dist-zip",
|
||||
"paketo-buildpacks/spring-boot");
|
||||
metadata.processOfType("web")
|
||||
.satisfiesExactly((command) -> assertThat(command).endsWith("sh"),
|
||||
(arg) -> assertThat(arg).endsWith("catalina.sh"),
|
||||
(arg) -> assertThat(arg).isEqualTo("run"));
|
||||
.containsSubsequence("java", "org.apache.catalina.startup.Bootstrap", "start");
|
||||
metadata.processOfType("tomcat")
|
||||
.satisfiesExactly((command) -> assertThat(command).endsWith("sh"),
|
||||
(arg) -> assertThat(arg).endsWith("catalina.sh"),
|
||||
(arg) -> assertThat(arg).isEqualTo("run"));
|
||||
.containsSubsequence("java", "org.apache.catalina.startup.Bootstrap", "start");
|
||||
});
|
||||
assertImageHasJvmSbomLayer(imageReference, config);
|
||||
assertImageHasDependenciesSbomLayer(imageReference, config, "apache-tomcat");
|
||||
|
|
|
@ -38,5 +38,6 @@ application {
|
|||
|
||||
bootBuildImage {
|
||||
archiveFile = bootDistZip.archiveFile
|
||||
builder = "paketobuildpacks/builder-jammy-base:latest"
|
||||
environment = ['BP_JVM_VERSION': java.targetCompatibility.getMajorVersion()]
|
||||
}
|
|
@ -38,5 +38,6 @@ application {
|
|||
|
||||
bootBuildImage {
|
||||
archiveFile = distZip.archiveFile
|
||||
builder = "paketobuildpacks/builder-jammy-base:latest"
|
||||
environment = ['BP_JVM_VERSION': java.targetCompatibility.getMajorVersion()]
|
||||
}
|
Loading…
Reference in New Issue
Block a user