Add runImage option for image building

This commit adds a runImage property to the Maven plugin build-image
goal and the Gradle bootBuildImage task. The property allows the user
to override the run image reference provided in the builder metadata
with an alternate run image. The runImage property can be specified
in the build file or on the command line.

Fixes gh-21534
This commit is contained in:
Scott Frederick
2020-06-11 16:20:39 -05:00
parent 025d7aaac8
commit 6119d69679
27 changed files with 427 additions and 89 deletions

View File

@@ -95,11 +95,12 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
.systemProperty("spring-boot.build-image.imageName", "example.com/test/cmd-property-name:v1")
.systemProperty("spring-boot.build-image.builder",
"gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3")
.systemProperty("spring-boot.build-image.runImage", "gcr.io/paketo-buildpacks/run:full-cnb-cf")
.execute((project) -> {
assertThat(buildLog(project)).contains("Building image")
.contains("example.com/test/cmd-property-name:v1")
.contains("paketo-buildpacks/builder:full-cf-platform-api-0.3")
.contains("Successfully built image");
.contains("paketo-buildpacks/run:full-cnb-cf").contains("Successfully built image");
ImageReference imageReference = ImageReference.of("example.com/test/cmd-property-name:v1");
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
@@ -111,10 +112,11 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
}
@TestTemplate
void whenBuildImageIsInvokedWithCustomBuilderImage(MavenBuild mavenBuild) {
void whenBuildImageIsInvokedWithCustomBuilderImageAndRunImage(MavenBuild mavenBuild) {
mavenBuild.project("build-image-custom-builder").goals("package").execute((project) -> {
assertThat(buildLog(project)).contains("Building image")
.contains("paketo-buildpacks/builder:full-cf-platform-api-0.3")
.contains("paketo-buildpacks/run:full-cnb-cf")
.contains("docker.io/library/build-image-v2-builder:0.0.1.BUILD-SNAPSHOT")
.contains("Successfully built image");
ImageReference imageReference = ImageReference

View File

@@ -24,6 +24,7 @@
<configuration>
<image>
<builder>gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3</builder>
<runImage>gcr.io/paketo-buildpacks/run:full-cnb-cf</runImage>
</image>
</configuration>
</execution>