Skip to content

Commit f3d717e

Browse files
Use paketo-buildpacks/builder as default builder
This commit changes the default builder image from `cloudfoundry/cnb:bionic-platform-api-0.2` to `gcr.io/paketo-buildpacks/builder:base-platform-api-0.3`. It also uses a `paketo-buildpacks/builder` image instead of a `cloudfoundry/cnb` image to test compatibility with lifecycle v2 and uses paketo naming instead of cloudfoundry when mocking builder interactions. Some adjustments to lifecycle phases were also made to align more closely with the pack CLI. Fixes gh-21066
1 parent 14c88b3 commit f3d717e

File tree

28 files changed

+95
-56
lines changed

28 files changed

+95
-56
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* Base class for {@link BuildLog} implementations.
3030
*
3131
* @author Phillip Webb
32+
* @author Scott Frederick
3233
* @since 2.3.0
3334
*/
3435
public abstract class AbstractBuildLog implements BuildLog {
@@ -73,6 +74,13 @@ public Consumer<LogUpdateEvent> runningPhase(BuildRequest request, String name)
7374
return (event) -> log(prefix + event);
7475
}
7576

77+
@Override
78+
public void skippingPhase(String name, String reason) {
79+
log();
80+
log(" > Skipping " + name + " " + reason);
81+
log();
82+
}
83+
7684
@Override
7785
public void executedLifecycle(BuildRequest request) {
7886
log();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* Callback interface used to provide {@link Builder} output logging.
3030
*
3131
* @author Phillip Webb
32+
* @author Scott Frederick
3233
* @since 2.3.0
3334
* @see #toSystemOut()
3435
*/
@@ -86,6 +87,13 @@ public interface BuildLog {
8687
*/
8788
Consumer<LogUpdateEvent> runningPhase(BuildRequest request, String name);
8889

90+
/**
91+
* Log that a specific phase is being skipped.
92+
* @param name the name of the phase
93+
* @param reason the reason the phase is skipped
94+
*/
95+
void skippingPhase(String name, String reason);
96+
8997
/**
9098
* Log that the lifecycle has executed.
9199
* @param request the build request

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

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

39-
static final String DEFAULT_BUILDER_IMAGE_NAME = "cloudfoundry/cnb:bionic-platform-api-0.2";
39+
static final String DEFAULT_BUILDER_IMAGE_NAME = "gcr.io/paketo-buildpacks/builder:base-platform-api-0.3";
4040

4141
private static final ImageReference DEFAULT_BUILDER = ImageReference.of(DEFAULT_BUILDER_IMAGE_NAME);
4242

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* application.
3737
*
3838
* @author Phillip Webb
39+
* @author Scott Frederick
3940
*/
4041
class Lifecycle implements Closeable {
4142

@@ -116,7 +117,12 @@ void execute() throws IOException {
116117
}
117118
run(detectPhase());
118119
run(analyzePhase());
119-
run(restorePhase());
120+
if (this.request.isCleanCache()) {
121+
this.log.skippingPhase("restorer", "due to cleaning cache");
122+
}
123+
else {
124+
run(restorePhase());
125+
}
120126
run(buildPhase());
121127
run(exportPhase());
122128
this.log.executedLifecycle(this.request);
@@ -144,12 +150,14 @@ private Phase analyzePhase() {
144150
Phase phase = createPhase("analyzer");
145151
phase.withDaemonAccess();
146152
phase.withLogLevelArg();
153+
phase.withArgs("-daemon");
147154
if (this.request.isCleanCache()) {
148155
phase.withArgs("-skip-layers");
149156
}
150-
phase.withArgs("-daemon");
157+
else {
158+
phase.withArgs("-cache-dir", Directory.CACHE);
159+
}
151160
phase.withArgs("-layers", Directory.LAYERS);
152-
phase.withArgs("-cache-dir", Directory.CACHE);
153161
phase.withArgs(this.request.getName());
154162
phase.withBinds(this.buildCacheVolume, Directory.CACHE);
155163
return phase;

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/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
58+
assertThat(request.getBuilder().toString()).isEqualTo(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/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
69+
assertThat(request.getBuilder().toString()).isEqualTo(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/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
75+
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
7676
.willAnswer(withPulledImage(builderImage));
7777
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
7878
.willAnswer(withPulledImage(runImage));
@@ -96,7 +96,7 @@ void buildWhenStackIdDoesNotMatchThrowsException() throws Exception {
9696
DockerApi docker = mockDockerApi();
9797
Image builderImage = loadImage("image.json");
9898
Image runImage = loadImage("run-image-with-bad-stack.json");
99-
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
99+
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
100100
.willAnswer(withPulledImage(builderImage));
101101
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
102102
.willAnswer(withPulledImage(runImage));
@@ -112,7 +112,7 @@ void buildWhenBuilderReturnsErrorThrowsException() throws Exception {
112112
DockerApi docker = mockDockerApiLifecycleError();
113113
Image builderImage = loadImage("image.json");
114114
Image runImage = loadImage("run-image.json");
115-
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
115+
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
116116
.willAnswer(withPulledImage(builderImage));
117117
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
118118
.willAnswer(withPulledImage(runImage));

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ void executeWhenCleanCacheClearsCache() throws Exception {
128128
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
129129
BuildRequest request = getTestRequest().withCleanCache(true);
130130
createLifecycle(request).execute();
131+
assertPhaseWasRun("detector", withExpectedConfig("lifecycle-detector.json"));
132+
assertPhaseWasRun("analyzer", withExpectedConfig("lifecycle-analyzer-clean-cache.json"));
133+
assertPhaseWasNotRun("restorer");
134+
assertPhaseWasRun("builder", withExpectedConfig("lifecycle-builder.json"));
135+
assertPhaseWasRun("exporter", withExpectedConfig("lifecycle-exporter.json"));
131136
VolumeName name = VolumeName.of("pack-cache-b35197ac41ea.build");
132137
verify(this.docker.volume()).delete(name, true);
133138
}
@@ -201,6 +206,11 @@ private void assertPhaseWasRun(String name, IOConsumer<ContainerConfig> configCo
201206
configConsumer.accept(this.configs.get(containerReference.toString()));
202207
}
203208

209+
private void assertPhaseWasNotRun(String name) {
210+
ContainerReference containerReference = ContainerReference.of("lifecycle-" + name);
211+
assertThat(this.configs.get(containerReference.toString())).isNull();
212+
}
213+
204214
private IOConsumer<ContainerConfig> withExpectedConfig(String name) {
205215
return (config) -> {
206216
InputStream in = getClass().getResourceAsStream(name);

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DockerApiIntegrationTests {
3535

3636
@Test
3737
void pullImage() throws IOException {
38-
this.docker.image().pull(ImageReference.of("cloudfoundry/cnb:bionic"),
38+
this.docker.image().pull(ImageReference.of("gcr.io/paketo-buildpacks/builder:base"),
3939
new TotalProgressPullListener(new TotalProgressBar("Pulling: ")));
4040
}
4141

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ void pullWhenListenerIsNullThrowsException() {
145145

146146
@Test
147147
void pullPullsImageAndProducesEvents() throws Exception {
148-
ImageReference reference = ImageReference.of("cloudfoundry/cnb:bionic");
149-
URI createUri = new URI(IMAGES_URL + "/create?fromImage=docker.io%2Fcloudfoundry%2Fcnb%3Abionic");
148+
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
149+
URI createUri = new URI(IMAGES_URL + "/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase");
150150
String imageHash = "4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30";
151-
URI imageUri = new URI(IMAGES_URL + "/docker.io/cloudfoundry/cnb@sha256:" + imageHash + "/json");
151+
URI imageUri = new URI(IMAGES_URL + "/gcr.io/paketo-buildpacks/builder@sha256:" + imageHash + "/json");
152152
given(http().post(createUri)).willReturn(responseOf("pull-stream.json"));
153153
given(http().get(imageUri)).willReturn(responseOf("type/image.json"));
154154
Image image = this.api.pull(reference, this.pullListener);

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/PullUpdateEventTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void readValueWhenMinimalDeserializesJson() throws Exception {
4545
PullImageUpdateEvent event = getObjectMapper().readValue(getContent("pull-update-minimal.json"),
4646
PullImageUpdateEvent.class);
4747
assertThat(event.getId()).isNull();
48-
assertThat(event.getStatus()).isEqualTo("Status: Downloaded newer image for cloudfoundry/cnb:bionic");
48+
assertThat(event.getStatus()).isEqualTo("Status: Downloaded newer image for packeto-buildpacks/cnb:base");
4949
assertThat(event.getProgressDetail()).isNull();
5050
assertThat(event.getProgress()).isNull();
5151
}

0 commit comments

Comments
 (0)