Use Paketo tiny builder by default for JVM and native apps

Closes gh-40859
This commit is contained in:
Scott Frederick
2024-06-28 11:30:43 -05:00
parent 99904d0307
commit 26b59ae912
13 changed files with 17 additions and 22 deletions

View File

@@ -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`.

View File

@@ -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.

View File

@@ -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) {

View File

@@ -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

View File

@@ -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

View File

@@ -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']}"
}
}