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

@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.entry;
* Tests for {@link Image}.
*
* @author Phillip Webb
* @author Scott Frederick
*/
class ImageTests {
@@ -58,6 +59,7 @@ class ImageTests {
BuildRequest request = new Image().getBuildRequest(createArtifact(), mockApplicationContent());
assertThat(request.getName().toString()).isEqualTo("docker.io/library/my-app:0.0.1-SNAPSHOT");
assertThat(request.getBuilder().toString()).contains("paketo-buildpacks/builder");
assertThat(request.getRunImage()).isNull();
assertThat(request.getEnv()).isEmpty();
assertThat(request.isCleanCache()).isFalse();
assertThat(request.isVerboseLogging()).isFalse();
@@ -71,6 +73,14 @@ class ImageTests {
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/springboot/builder:2.2.x");
}
@Test
void getBuildRequestWhenHasRunImageUsesRunImage() {
Image image = new Image();
image.runImage = "springboot/run:latest";
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
assertThat(request.getRunImage().toString()).isEqualTo("docker.io/springboot/run:latest");
}
@Test
void getBuildRequestWhenHasEnvUsesEnv() {
Image image = new Image();