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
This commit is contained in:
@@ -29,6 +29,7 @@ import org.springframework.boot.buildpack.platform.docker.type.VolumeName;
|
||||
* Base class for {@link BuildLog} implementations.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public abstract class AbstractBuildLog implements BuildLog {
|
||||
@@ -73,6 +74,13 @@ public abstract class AbstractBuildLog implements BuildLog {
|
||||
return (event) -> log(prefix + event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skippingPhase(String name, String reason) {
|
||||
log();
|
||||
log(" > Skipping " + name + " " + reason);
|
||||
log();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executedLifecycle(BuildRequest request) {
|
||||
log();
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.boot.buildpack.platform.docker.type.VolumeName;
|
||||
* Callback interface used to provide {@link Builder} output logging.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @since 2.3.0
|
||||
* @see #toSystemOut()
|
||||
*/
|
||||
@@ -86,6 +87,13 @@ public interface BuildLog {
|
||||
*/
|
||||
Consumer<LogUpdateEvent> runningPhase(BuildRequest request, String name);
|
||||
|
||||
/**
|
||||
* Log that a specific phase is being skipped.
|
||||
* @param name the name of the phase
|
||||
* @param reason the reason the phase is skipped
|
||||
*/
|
||||
void skippingPhase(String name, String reason);
|
||||
|
||||
/**
|
||||
* Log that the lifecycle has executed.
|
||||
* @param request the build request
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class BuildRequest {
|
||||
|
||||
static final String DEFAULT_BUILDER_IMAGE_NAME = "cloudfoundry/cnb:bionic-platform-api-0.2";
|
||||
static final String DEFAULT_BUILDER_IMAGE_NAME = "gcr.io/paketo-buildpacks/builder:base-platform-api-0.3";
|
||||
|
||||
private static final ImageReference DEFAULT_BUILDER = ImageReference.of(DEFAULT_BUILDER_IMAGE_NAME);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
* application.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
class Lifecycle implements Closeable {
|
||||
|
||||
@@ -116,7 +117,12 @@ class Lifecycle implements Closeable {
|
||||
}
|
||||
run(detectPhase());
|
||||
run(analyzePhase());
|
||||
run(restorePhase());
|
||||
if (this.request.isCleanCache()) {
|
||||
this.log.skippingPhase("restorer", "due to cleaning cache");
|
||||
}
|
||||
else {
|
||||
run(restorePhase());
|
||||
}
|
||||
run(buildPhase());
|
||||
run(exportPhase());
|
||||
this.log.executedLifecycle(this.request);
|
||||
@@ -144,12 +150,14 @@ class Lifecycle implements Closeable {
|
||||
Phase phase = createPhase("analyzer");
|
||||
phase.withDaemonAccess();
|
||||
phase.withLogLevelArg();
|
||||
phase.withArgs("-daemon");
|
||||
if (this.request.isCleanCache()) {
|
||||
phase.withArgs("-skip-layers");
|
||||
}
|
||||
phase.withArgs("-daemon");
|
||||
else {
|
||||
phase.withArgs("-cache-dir", Directory.CACHE);
|
||||
}
|
||||
phase.withArgs("-layers", Directory.LAYERS);
|
||||
phase.withArgs("-cache-dir", Directory.CACHE);
|
||||
phase.withArgs(this.request.getName());
|
||||
phase.withBinds(this.buildCacheVolume, Directory.CACHE);
|
||||
return phase;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BuildRequestTests {
|
||||
writeTestJarFile(jarFile);
|
||||
BuildRequest request = BuildRequest.forJarFile(jarFile);
|
||||
assertThat(request.getName().toString()).isEqualTo("docker.io/library/my-app:0.0.1");
|
||||
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
|
||||
assertThat(request.getBuilder().toString()).isEqualTo(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
|
||||
assertThat(request.getApplicationContent(Owner.ROOT)).satisfies(this::hasExpectedJarContent);
|
||||
assertThat(request.getEnv()).isEmpty();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class BuildRequestTests {
|
||||
writeTestJarFile(jarFile);
|
||||
BuildRequest request = BuildRequest.forJarFile(ImageReference.of("test-app"), jarFile);
|
||||
assertThat(request.getName().toString()).isEqualTo("docker.io/library/test-app:latest");
|
||||
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
|
||||
assertThat(request.getBuilder().toString()).isEqualTo(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME);
|
||||
assertThat(request.getApplicationContent(Owner.ROOT)).satisfies(this::hasExpectedJarContent);
|
||||
assertThat(request.getEnv()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class BuilderTests {
|
||||
DockerApi docker = mockDockerApi();
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
@@ -96,7 +96,7 @@ class BuilderTests {
|
||||
DockerApi docker = mockDockerApi();
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image-with-bad-stack.json");
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
@@ -112,7 +112,7 @@ class BuilderTests {
|
||||
DockerApi docker = mockDockerApiLifecycleError();
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/" + BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
|
||||
@@ -128,6 +128,11 @@ class LifecycleTests {
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
BuildRequest request = getTestRequest().withCleanCache(true);
|
||||
createLifecycle(request).execute();
|
||||
assertPhaseWasRun("detector", withExpectedConfig("lifecycle-detector.json"));
|
||||
assertPhaseWasRun("analyzer", withExpectedConfig("lifecycle-analyzer-clean-cache.json"));
|
||||
assertPhaseWasNotRun("restorer");
|
||||
assertPhaseWasRun("builder", withExpectedConfig("lifecycle-builder.json"));
|
||||
assertPhaseWasRun("exporter", withExpectedConfig("lifecycle-exporter.json"));
|
||||
VolumeName name = VolumeName.of("pack-cache-b35197ac41ea.build");
|
||||
verify(this.docker.volume()).delete(name, true);
|
||||
}
|
||||
@@ -201,6 +206,11 @@ class LifecycleTests {
|
||||
configConsumer.accept(this.configs.get(containerReference.toString()));
|
||||
}
|
||||
|
||||
private void assertPhaseWasNotRun(String name) {
|
||||
ContainerReference containerReference = ContainerReference.of("lifecycle-" + name);
|
||||
assertThat(this.configs.get(containerReference.toString())).isNull();
|
||||
}
|
||||
|
||||
private IOConsumer<ContainerConfig> withExpectedConfig(String name) {
|
||||
return (config) -> {
|
||||
InputStream in = getClass().getResourceAsStream(name);
|
||||
|
||||
@@ -35,7 +35,7 @@ class DockerApiIntegrationTests {
|
||||
|
||||
@Test
|
||||
void pullImage() throws IOException {
|
||||
this.docker.image().pull(ImageReference.of("cloudfoundry/cnb:bionic"),
|
||||
this.docker.image().pull(ImageReference.of("gcr.io/paketo-buildpacks/builder:base"),
|
||||
new TotalProgressPullListener(new TotalProgressBar("Pulling: ")));
|
||||
}
|
||||
|
||||
|
||||
@@ -145,10 +145,10 @@ class DockerApiTests {
|
||||
|
||||
@Test
|
||||
void pullPullsImageAndProducesEvents() throws Exception {
|
||||
ImageReference reference = ImageReference.of("cloudfoundry/cnb:bionic");
|
||||
URI createUri = new URI(IMAGES_URL + "/create?fromImage=docker.io%2Fcloudfoundry%2Fcnb%3Abionic");
|
||||
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
|
||||
URI createUri = new URI(IMAGES_URL + "/create?fromImage=gcr.io%2Fpaketo-buildpacks%2Fbuilder%3Abase");
|
||||
String imageHash = "4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30";
|
||||
URI imageUri = new URI(IMAGES_URL + "/docker.io/cloudfoundry/cnb@sha256:" + imageHash + "/json");
|
||||
URI imageUri = new URI(IMAGES_URL + "/gcr.io/paketo-buildpacks/builder@sha256:" + imageHash + "/json");
|
||||
given(http().post(createUri)).willReturn(responseOf("pull-stream.json"));
|
||||
given(http().get(imageUri)).willReturn(responseOf("type/image.json"));
|
||||
Image image = this.api.pull(reference, this.pullListener);
|
||||
|
||||
@@ -45,7 +45,7 @@ class PullUpdateEventTests extends AbstractJsonTests {
|
||||
PullImageUpdateEvent event = getObjectMapper().readValue(getContent("pull-update-minimal.json"),
|
||||
PullImageUpdateEvent.class);
|
||||
assertThat(event.getId()).isNull();
|
||||
assertThat(event.getStatus()).isEqualTo("Status: Downloaded newer image for cloudfoundry/cnb:bionic");
|
||||
assertThat(event.getStatus()).isEqualTo("Status: Downloaded newer image for packeto-buildpacks/cnb:base");
|
||||
assertThat(event.getProgressDetail()).isNull();
|
||||
assertThat(event.getProgress()).isNull();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link JsonStream}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
*/
|
||||
class JsonStreamTests extends AbstractJsonTests {
|
||||
|
||||
@@ -43,7 +44,8 @@ class JsonStreamTests extends AbstractJsonTests {
|
||||
List<ObjectNode> result = new ArrayList<>();
|
||||
this.jsonStream.get(getContent("stream.json"), result::add);
|
||||
assertThat(result).hasSize(595);
|
||||
assertThat(result.get(594).toString()).contains("Status: Downloaded newer image for cloudfoundry/cnb:bionic");
|
||||
assertThat(result.get(594).toString())
|
||||
.contains("Status: Downloaded newer image for packeto-buildpacks/cnb:base");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,7 +54,8 @@ class JsonStreamTests extends AbstractJsonTests {
|
||||
this.jsonStream.get(getContent("stream.json"), TestEvent.class, result::add);
|
||||
assertThat(result).hasSize(595);
|
||||
assertThat(result.get(1).getId()).isEqualTo("5667fdb72017");
|
||||
assertThat(result.get(594).getStatus()).isEqualTo("Status: Downloaded newer image for cloudfoundry/cnb:bionic");
|
||||
assertThat(result.get(594).getStatus())
|
||||
.isEqualTo("Status: Downloaded newer image for packeto-buildpacks/cnb:base");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"Id": "sha256:44cc64492fb6a6d78d3e6d087f380ae6e479aa1b2c79823b32cdacfcc2f3d715",
|
||||
"RepoTags": [
|
||||
"cloudfoundry/cnb:bionic",
|
||||
"cloudfoundry/cnb:bionic-platform-api-0.3"
|
||||
"paketo-buildpacks/cnb:base",
|
||||
"paketo-buildpacks/builder:base-platform-api-0.2"
|
||||
],
|
||||
"RepoDigests": [
|
||||
"cloudfoundry/cnb@sha256:5b03a853e636b78c44e475bbc514e2b7b140cc41cca8ab907e9753431ae8c0b0"
|
||||
"packeto-buidpacks/cnb@sha256:5b03a853e636b78c44e475bbc514e2b7b140cc41cca8ab907e9753431ae8c0b0"
|
||||
],
|
||||
"Parent": "",
|
||||
"Comment": "",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"User" : "root",
|
||||
"Image" : "pack.local/ephemeral-builder",
|
||||
"Cmd" : [ "/lifecycle/cacher", "-path", "/cache", "-layers", "/layers" ],
|
||||
"Cmd" : [ "/lifecycle/analyzer", "-daemon", "-skip-layers", "-layers", "/layers", "docker.io/library/my-application:latest" ],
|
||||
"Labels" : {
|
||||
"author" : "spring-boot"
|
||||
},
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"User" : "root",
|
||||
"Image" : "pack.local/ephemeral-builder",
|
||||
"Cmd" : [ "/lifecycle/analyzer", "-daemon", "-layers", "/layers", "-cache-dir", "/cache", "docker.io/library/my-application:latest" ],
|
||||
"Cmd" : [ "/lifecycle/analyzer", "-daemon", "-cache-dir", "/cache", "-layers", "/layers", "docker.io/library/my-application:latest" ],
|
||||
"Labels" : {
|
||||
"author" : "spring-boot"
|
||||
},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"Id": "sha256:9b450bffdb05bcf660d464d0bfdf344ee6ca38e9b8de4f408c8080b0c9319349",
|
||||
"RepoTags": [
|
||||
"cloudfoundry/cnb:latest"
|
||||
"packeto-buildpacks/cnb:latest"
|
||||
],
|
||||
"RepoDigests": [
|
||||
"cloudfoundry/run@sha256:715806bb793b66e3fc1a5a8f5584c6a1b6db05425e573887673bddcf426f1b90"
|
||||
"packeto-buildpacks/run@sha256:715806bb793b66e3fc1a5a8f5584c6a1b6db05425e573887673bddcf426f1b90"
|
||||
],
|
||||
"Parent": "",
|
||||
"Comment": "",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"status": "Pulling from cloudfoundry/cnb",
|
||||
"id": "bionic"
|
||||
"status": "Pulling from packeto-buildpacks/cnb",
|
||||
"id": "base"
|
||||
}
|
||||
{"status":"Pulling fs layer","progressDetail":{},"id":"5667fdb72017"}
|
||||
{"status":"Pulling fs layer","progressDetail":{},"id":"d83811f270d5"}
|
||||
@@ -595,4 +595,4 @@
|
||||
{"status":"Extracting","progressDetail":{"current":32,"total":32},"progress":"[==================================================\u003e] 32B/32B","id":"4f4fb700ef54"}
|
||||
{"status":"Pull complete","progressDetail":{},"id":"4f4fb700ef54"}
|
||||
{"status":"Digest: sha256:4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30"}
|
||||
{"status":"Status: Downloaded newer image for cloudfoundry/cnb:bionic"}
|
||||
{"status":"Status: Downloaded newer image for packeto-buildpacks/cnb:base"}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"status": "Status: Downloaded newer image for cloudfoundry/cnb:bionic"
|
||||
"status": "Status: Downloaded newer image for packeto-buildpacks/cnb:base"
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"Id": "sha256:9b450bffdb05bcf660d464d0bfdf344ee6ca38e9b8de4f408c8080b0c9319349",
|
||||
"RepoTags": [
|
||||
"cloudfoundry/cnb:latest"
|
||||
"packeto-buildpacks/cnb:latest"
|
||||
],
|
||||
"RepoDigests": [
|
||||
"cloudfoundry/cnb@sha256:915802bb193b66e3fc1a5a8f5584c6a1b6db05425e573887673bddcf426f1b90"
|
||||
"packeto-buildpacks/cnb@sha256:915802bb193b66e3fc1a5a8f5584c6a1b6db05425e573887673bddcf426f1b90"
|
||||
],
|
||||
"Parent": "",
|
||||
"Comment": "",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"status": "Pulling from cloudfoundry/cnb",
|
||||
"id": "bionic"
|
||||
"status": "Pulling from packeto-buildpacks/cnb",
|
||||
"id": "base"
|
||||
}
|
||||
{"status":"Pulling fs layer","progressDetail":{},"id":"5667fdb72017"}
|
||||
{"status":"Pulling fs layer","progressDetail":{},"id":"d83811f270d5"}
|
||||
@@ -595,4 +595,4 @@
|
||||
{"status":"Extracting","progressDetail":{"current":32,"total":32},"progress":"[==================================================\u003e] 32B/32B","id":"4f4fb700ef54"}
|
||||
{"status":"Pull complete","progressDetail":{},"id":"4f4fb700ef54"}
|
||||
{"status":"Digest: sha256:4acb6bfd6c4f0cabaf7f3690e444afe51f1c7de54d51da7e63fac709c56f1c30"}
|
||||
{"status":"Status: Downloaded newer image for cloudfoundry/cnb:bionic"}
|
||||
{"status":"Status: Downloaded newer image for packeto-buildpacks/cnb:base"}
|
||||
|
||||
Reference in New Issue
Block a user