Skip to content

Commit bb9e37e

Browse files
Use platform API builder image tags
CNB builder images are now being tagged in a manner that indicates the version of the platform API implemented. This allows Spring Boot to default to a builder tag that guarantees API compatibility while allowing for updates to bundled buildpacks. Fixes gh-20171
1 parent 4dad56a commit bb9e37e

File tree

10 files changed

+21
-18
lines changed

10 files changed

+21
-18
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
*/
3737
public class BuildRequest {
3838

39-
private static final ImageReference DEFAULT_BUILDER = ImageReference.of("cloudfoundry/cnb:0.0.53-bionic");
39+
static final String DEFAULT_BUILDER_IMAGE_NAME = "cloudfoundry/cnb:bionic-platform-api-0.2";
40+
41+
private static final ImageReference DEFAULT_BUILDER = ImageReference.of(DEFAULT_BUILDER_IMAGE_NAME);
4042

4143
private final ImageReference name;
4244

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void forJarFileReturnsRequest() throws IOException {
5555
writeTestJarFile(jarFile);
5656
BuildRequest request = BuildRequest.forJarFile(jarFile);
5757
assertThat(request.getName().toString()).isEqualTo("docker.io/library/my-app:0.0.1");
58-
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/cloudfoundry/cnb:0.0.53-bionic");
58+
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
5959
assertThat(request.getApplicationContent(Owner.ROOT)).satisfies(this::hasExpectedJarContent);
6060
assertThat(request.getEnv()).isEmpty();
6161
}
@@ -66,7 +66,7 @@ void forJarFileWithNameReturnsRequest() throws IOException {
6666
writeTestJarFile(jarFile);
6767
BuildRequest request = BuildRequest.forJarFile(ImageReference.of("test-app"), jarFile);
6868
assertThat(request.getName().toString()).isEqualTo("docker.io/library/test-app:latest");
69-
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/cloudfoundry/cnb:0.0.53-bionic");
69+
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
7070
assertThat(request.getApplicationContent(Owner.ROOT)).satisfies(this::hasExpectedJarContent);
7171
assertThat(request.getEnv()).isEmpty();
7272
}

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void buildInvokesBuilder() throws Exception {
7272
DockerApi docker = mockDockerApi();
7373
Image builderImage = loadImage("image.json");
7474
Image runImage = loadImage("run-image.json");
75-
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/cnb:0.0.53-bionic")), any()))
75+
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
7676
.willAnswer(withPulledImage(builderImage));
7777
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:full-cnb")), any()))
7878
.willAnswer(withPulledImage(runImage));
@@ -97,7 +97,7 @@ void buildWhenStackIdDoesNotMatchThrowsException() throws Exception {
9797
DockerApi docker = mockDockerApi();
9898
Image builderImage = loadImage("image.json");
9999
Image runImage = loadImage("run-image-with-bad-stack.json");
100-
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/cnb:0.0.53-bionic")), any()))
100+
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
101101
.willAnswer(withPulledImage(builderImage));
102102
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:full-cnb")), any()))
103103
.willAnswer(withPulledImage(runImage));
@@ -113,7 +113,7 @@ void buildWhenBuilderReturnsErrorThrowsException() throws Exception {
113113
DockerApi docker = mockDockerApiLifecycleError();
114114
Image builderImage = loadImage("image.json");
115115
Image runImage = loadImage("run-image.json");
116-
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/cnb:0.0.53-bionic")), any()))
116+
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
117117
.willAnswer(withPulledImage(builderImage));
118118
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:full-cnb")), any()))
119119
.willAnswer(withPulledImage(runImage));

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following table summarizes the available properties and their default values
4848
| `builder`
4949
| `--builder`
5050
| Name of the Builder image to use.
51-
| `cloudfoundry/cnb:0.0.53-bionic`
51+
| `cloudfoundry/cnb:bionic-platform-api-0.2`
5252

5353
| `imageName`
5454
| `--imageName`

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void buildsImageWithDefaultBuilder() throws IOException {
6161
String projectName = this.gradleBuild.getProjectDir().getName();
6262
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
6363
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
64-
assertThat(result.getOutput()).contains("cloudfoundry/cnb:0.0.53-bionic");
64+
assertThat(result.getOutput()).contains("cloudfoundry/cnb:bionic-platform-api");
6565
ImageReference imageReference = ImageReference.of(ImageName.of(projectName));
6666
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
6767
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
@@ -78,7 +78,7 @@ void buildsImageWithCustomName() throws IOException {
7878
BuildResult result = this.gradleBuild.build("bootBuildImage");
7979
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
8080
assertThat(result.getOutput()).contains("example.com/test-image-name");
81-
assertThat(result.getOutput()).contains("cloudfoundry/cnb:0.0.53-bionic");
81+
assertThat(result.getOutput()).contains("cloudfoundry/cnb:bionic-platform-api");
8282
ImageReference imageReference = ImageReference.of(ImageName.of("example.com/test-image-name"));
8383
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
8484
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
@@ -96,7 +96,7 @@ void buildsImageWithV1Builder() throws IOException {
9696
String projectName = this.gradleBuild.getProjectDir().getName();
9797
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
9898
assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
99-
assertThat(result.getOutput()).contains("cloudfoundry/cnb:0.0.43-bionic");
99+
assertThat(result.getOutput()).contains("cloudfoundry/cnb:bionic-platform-api-0.1");
100100
ImageReference imageReference = ImageReference.of(ImageName.of(projectName));
101101
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
102102
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithV1Builder.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ sourceCompatibility = '1.8'
77
targetCompatibility = '1.8'
88

99
bootBuildImage {
10-
builder = "cloudfoundry/cnb:0.0.43-bionic"
10+
builder = "cloudfoundry/cnb:bionic-platform-api-0.1"
1111
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The following table summarizes the available parameters and their default values
7373
| `builder`
7474
| Name of the Builder image to use.
7575
| `spring-boot.build-image.builder`
76-
| `cloudfoundry/cnb:0.0.53-bionic`
76+
| `cloudfoundry/cnb:bionic-platform-api-0.2`
7777

7878
| `name`
7979
| {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[Image name] for the generated image.

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void whenBuildImageIsInvokedWithoutRepackageTheArchiveIsRepackagedOnTheFly(Maven
5252
assertThat(jar).isFile();
5353
File original = new File(project, "target/build-image-0.0.1.BUILD-SNAPSHOT.jar.original");
5454
assertThat(original).doesNotExist();
55-
assertThat(buildLog(project)).contains("Building image").contains("cloudfoundry/cnb:0.0.53-bionic")
55+
assertThat(buildLog(project)).contains("Building image").contains("cloudfoundry/cnb:bionic-platform-api")
5656
.contains("docker.io/library/build-image:0.0.1.BUILD-SNAPSHOT")
5757
.contains("Successfully built image");
5858
ImageReference imageReference = ImageReference.of(ImageName.of("build-image"), "0.0.1.BUILD-SNAPSHOT");
@@ -93,11 +93,11 @@ void whenBuildImageIsInvokedWithCustomImageName(MavenBuild mavenBuild) {
9393
void whenBuildImageIsInvokedWithCommandLineParameters(MavenBuild mavenBuild) {
9494
mavenBuild.project("build-image").goals("package")
9595
.systemProperty("spring-boot.build-image.imageName", "example.com/test/cmd-property-name:v1")
96-
.systemProperty("spring-boot.build-image.builder", "cloudfoundry/cnb:0.0.43-bionic")
96+
.systemProperty("spring-boot.build-image.builder", "cloudfoundry/cnb:bionic-platform-api-0.1")
9797
.execute((project) -> {
9898
assertThat(buildLog(project)).contains("Building image")
9999
.contains("example.com/test/cmd-property-name:v1")
100-
.contains("cloudfoundry/cnb:0.0.43-bionic").contains("Successfully built image");
100+
.contains("cloudfoundry/cnb:bionic-platform-api-0.1").contains("Successfully built image");
101101
ImageReference imageReference = ImageReference.of("example.com/test/cmd-property-name:v1");
102102
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
103103
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
@@ -111,7 +111,8 @@ void whenBuildImageIsInvokedWithCommandLineParameters(MavenBuild mavenBuild) {
111111
@TestTemplate
112112
void whenBuildImageIsInvokedWithV1BuilderImage(MavenBuild mavenBuild) {
113113
mavenBuild.project("build-image-v1-builder").goals("package").execute((project) -> {
114-
assertThat(buildLog(project)).contains("Building image").contains("cloudfoundry/cnb:0.0.43-bionic")
114+
assertThat(buildLog(project)).contains("Building image")
115+
.contains("cloudfoundry/cnb:bionic-platform-api-0.1")
115116
.contains("docker.io/library/build-image-v1-builder:0.0.1.BUILD-SNAPSHOT")
116117
.contains("Successfully built image");
117118
ImageReference imageReference = ImageReference

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v1-builder/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</goals>
2424
<configuration>
2525
<image>
26-
<builder>cloudfoundry/cnb:0.0.43-bionic</builder>
26+
<builder>cloudfoundry/cnb:bionic-platform-api-0.1</builder>
2727
</image>
2828
</configuration>
2929
</execution>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ImageTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void getBuildEquestWhenNameIsSetUsesName() {
5757
void getBuildRequestWhenNoCustomizationsUsesDefaults() {
5858
BuildRequest request = new Image().getBuildRequest(createArtifact(), mockAplicationContent());
5959
assertThat(request.getName().toString()).isEqualTo("docker.io/library/my-app:0.0.1-SNAPSHOT");
60-
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/cloudfoundry/cnb:0.0.53-bionic");
60+
assertThat(request.getBuilder().toString()).contains("docker.io/cloudfoundry/cnb:bionic-platform-api");
6161
assertThat(request.getEnv()).isEmpty();
6262
assertThat(request.isCleanCache()).isFalse();
6363
assertThat(request.isVerboseLogging()).isFalse();

0 commit comments

Comments
 (0)