From 35bc82a6933556be551aed23ceea4c14a60cf8ee Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Thu, 30 Apr 2020 15:45:01 -0500 Subject: [PATCH] Use CNB creator all-in-one lifecycle This commit modifies the buildpack platform invocation logic used by the build plugins to invoke the single creator lifecycle introduced in the CNB API 0.3, instead of invoking discrete lifecycle phases separately. It also removes support for CNB API 0.2. Fixes gh-21273 --- .../buildpack/platform/build/ApiVersions.java | 2 +- .../buildpack/platform/build/Lifecycle.java | 81 ++++--------------- .../platform/build/BuilderTests.java | 8 +- .../platform/build/LifecycleTests.java | 23 ++---- .../build/lifecycle-analyzer-clean-cache.json | 11 --- .../platform/build/lifecycle-analyzer.json | 11 --- .../platform/build/lifecycle-builder.json | 10 --- .../build/lifecycle-creator-clean-cache.json | 11 +++ .../platform/build/lifecycle-creator.json | 11 +++ .../platform/build/lifecycle-detector.json | 10 --- .../platform/build/lifecycle-exporter.json | 11 --- .../platform/build/lifecycle-restorer.json | 11 --- .../BootBuildImageIntegrationTests.java | 20 ++--- ...Tests-buildsImageWithCustomBuilder.gradle} | 4 +- .../boot/maven/BuildImageTests.java | 12 +-- .../pom.xml | 2 +- .../main/java/org/test/SampleApplication.java | 0 17 files changed, 64 insertions(+), 174 deletions(-) delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer-clean-cache.json delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer.json delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-builder.json create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator-clean-cache.json create mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator.json delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-detector.json delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-exporter.json delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-restorer.json rename spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/{BootBuildImageIntegrationTests-buildsImageWithV2Builder.gradle => BootBuildImageIntegrationTests-buildsImageWithCustomBuilder.gradle} (57%) rename spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/{build-image-v2-builder => build-image-custom-builder}/pom.xml (92%) rename spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/{build-image-v2-builder => build-image-custom-builder}/src/main/java/org/test/SampleApplication.java (100%) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersions.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersions.java index 376b7fb052..33fbc10e1b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersions.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersions.java @@ -32,7 +32,7 @@ final class ApiVersions { /** * The platform API versions supported by this release. */ - static final ApiVersions SUPPORTED_PLATFORMS = new ApiVersions(ApiVersion.of(0, 2), ApiVersion.of(0, 3)); + static final ApiVersions SUPPORTED_PLATFORMS = new ApiVersions(ApiVersion.of(0, 3)); private final ApiVersion[] apiVersions; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Lifecycle.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Lifecycle.java index 673b563a3d..1b343adf7d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Lifecycle.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Lifecycle.java @@ -115,87 +115,36 @@ class Lifecycle implements Closeable { if (this.request.isCleanCache()) { deleteVolume(this.buildCacheVolume); } - run(detectPhase()); - run(analyzePhase()); - if (this.request.isCleanCache()) { - this.log.skippingPhase("restorer", "due to cleaning cache"); - } - else { - run(restorePhase()); - } - run(buildPhase()); - run(exportPhase()); + run(createPhase()); this.log.executedLifecycle(this.request); } - private Phase detectPhase() { - Phase phase = createPhase("detector"); + private Phase createPhase() { + Phase phase = new Phase("creator", isVerboseLogging()); + phase.withDaemonAccess(); + phase.withLogLevelArg(); phase.withArgs("-app", Directory.APPLICATION); phase.withArgs("-platform", Directory.PLATFORM); - phase.withLogLevelArg(); - return phase; - } - - private Phase restorePhase() { - Phase phase = createPhase("restorer"); - phase.withDaemonAccess(); - phase.withArgs("-cache-dir", Directory.CACHE); + phase.withArgs("-run-image", this.runImageReference); phase.withArgs("-layers", Directory.LAYERS); - phase.withLogLevelArg(); - phase.withBinds(this.buildCacheVolume, Directory.CACHE); - return phase; - } - - private Phase analyzePhase() { - Phase phase = createPhase("analyzer"); - phase.withDaemonAccess(); - phase.withLogLevelArg(); + phase.withArgs("-cache-dir", Directory.CACHE); + phase.withArgs("-launch-cache", Directory.LAUNCH_CACHE); phase.withArgs("-daemon"); if (this.request.isCleanCache()) { - phase.withArgs("-skip-layers"); + phase.withArgs("-skip-restore"); } - else { - phase.withArgs("-cache-dir", Directory.CACHE); - } - phase.withArgs("-layers", Directory.LAYERS); phase.withArgs(this.request.getName()); - phase.withBinds(this.buildCacheVolume, Directory.CACHE); - return phase; - } - - private Phase buildPhase() { - Phase phase = createPhase("builder"); - phase.withArgs("-layers", Directory.LAYERS); - phase.withArgs("-app", Directory.APPLICATION); - phase.withArgs("-platform", Directory.PLATFORM); - return phase; - } - - private Phase exportPhase() { - Phase phase = createPhase("exporter"); - phase.withDaemonAccess(); - phase.withLogLevelArg(); - phase.withArgs("-image", this.runImageReference); - phase.withArgs("-layers", Directory.LAYERS); - phase.withArgs("-app", Directory.APPLICATION); - phase.withArgs("-daemon"); - phase.withArgs("-launch-cache", Directory.LAUNCH_CACHE); - phase.withArgs("-cache-dir", Directory.CACHE); - phase.withArgs(this.request.getName()); - phase.withBinds(this.launchCacheVolume, Directory.LAUNCH_CACHE); - phase.withBinds(this.buildCacheVolume, Directory.CACHE); - return phase; - } - - private Phase createPhase(String name) { - boolean verboseLogging = this.request.isVerboseLogging() - && this.lifecycleVersion.isEqualOrGreaterThan(LOGGING_MINIMUM_VERSION); - Phase phase = new Phase(name, verboseLogging); phase.withBinds(this.layersVolume, Directory.LAYERS); phase.withBinds(this.applicationVolume, Directory.APPLICATION); + phase.withBinds(this.buildCacheVolume, Directory.CACHE); + phase.withBinds(this.launchCacheVolume, Directory.LAUNCH_CACHE); return phase; } + private boolean isVerboseLogging() { + return this.request.isVerboseLogging() && this.lifecycleVersion.isEqualOrGreaterThan(LOGGING_MINIMUM_VERSION); + } + private void run(Phase phase) throws IOException { Consumer logConsumer = this.log.runningPhase(this.request, phase.getName()); ContainerConfig containerConfig = ContainerConfig.of(this.builder.getName(), phase::apply); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java index 594d1b3fd9..7b1576cc80 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuilderTests.java @@ -79,11 +79,7 @@ class BuilderTests { Builder builder = new Builder(BuildLog.to(out), docker); BuildRequest request = getTestRequest(); builder.build(request); - assertThat(out.toString()).contains("Running detector"); - assertThat(out.toString()).contains("Running restorer"); - assertThat(out.toString()).contains("Running analyzer"); - assertThat(out.toString()).contains("Running builder"); - assertThat(out.toString()).contains("Running exporter"); + assertThat(out.toString()).contains("Running creator"); assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); ArgumentCaptor archive = ArgumentCaptor.forClass(ImageArchive.class); verify(docker.image()).load(archive.capture(), any()); @@ -119,7 +115,7 @@ class BuilderTests { Builder builder = new Builder(BuildLog.to(out), docker); BuildRequest request = getTestRequest(); assertThatExceptionOfType(BuilderException.class).isThrownBy(() -> builder.build(request)) - .withMessage("Builder lifecycle 'detector' failed with status code 9"); + .withMessage("Builder lifecycle 'creator' failed with status code 9"); } private DockerApi mockDockerApi() throws IOException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java index 183e443fa0..298fdb72a2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/LifecycleTests.java @@ -68,9 +68,9 @@ class LifecycleTests { private DockerApi docker; - private Map configs = new LinkedHashMap<>(); + private final Map configs = new LinkedHashMap<>(); - private Map content = new LinkedHashMap<>(); + private final Map content = new LinkedHashMap<>(); @BeforeEach void setup() { @@ -84,11 +84,7 @@ class LifecycleTests { given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId()); given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null)); createLifecycle().execute(); - assertPhaseWasRun("detector", withExpectedConfig("lifecycle-detector.json")); - assertPhaseWasRun("analyzer", withExpectedConfig("lifecycle-analyzer.json")); - assertPhaseWasRun("restorer", withExpectedConfig("lifecycle-restorer.json")); - assertPhaseWasRun("builder", withExpectedConfig("lifecycle-builder.json")); - assertPhaseWasRun("exporter", withExpectedConfig("lifecycle-exporter.json")); + assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator.json")); assertThat(this.out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'"); } @@ -118,7 +114,7 @@ class LifecycleTests { given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId()); given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(9, null)); assertThatExceptionOfType(BuilderException.class).isThrownBy(() -> createLifecycle().execute()) - .withMessage("Builder lifecycle 'detector' failed with status code 9"); + .withMessage("Builder lifecycle 'creator' failed with status code 9"); } @Test @@ -128,11 +124,7 @@ 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")); + assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-clean-cache.json")); VolumeName name = VolumeName.of("pack-cache-b35197ac41ea.build"); verify(this.docker.volume()).delete(name, true); } @@ -206,11 +198,6 @@ 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 withExpectedConfig(String name) { return (config) -> { InputStream in = getClass().getResourceAsStream(name); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer-clean-cache.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer-clean-cache.json deleted file mode 100644 index 47b9218f2e..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer-clean-cache.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "User" : "root", - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/analyzer", "-daemon", "-skip-layers", "-layers", "/layers", "docker.io/library/my-application:latest" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer.json deleted file mode 100644 index 7306be0f89..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-analyzer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "User" : "root", - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/analyzer", "-daemon", "-cache-dir", "/cache", "-layers", "/layers", "docker.io/library/my-application:latest" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-builder.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-builder.json deleted file mode 100644 index 54153a9155..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-builder.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/builder", "-layers", "/layers", "-app", "/workspace", "-platform", "/platform" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator-clean-cache.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator-clean-cache.json new file mode 100644 index 0000000000..9572eba148 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator-clean-cache.json @@ -0,0 +1,11 @@ +{ + "User" : "root", + "Image" : "pack.local/ephemeral-builder", + "Cmd" : [ "/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "-skip-restore", "docker.io/library/my-application:latest" ], + "Labels" : { + "author" : "spring-boot" + }, + "HostConfig" : { + "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache" ] + } +} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator.json new file mode 100644 index 0000000000..e26bbcf6a5 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-creator.json @@ -0,0 +1,11 @@ +{ + "User" : "root", + "Image" : "pack.local/ephemeral-builder", + "Cmd" : [ "/lifecycle/creator", "-app", "/workspace", "-platform", "/platform", "-run-image", "docker.io/cloudfoundry/run", "-layers", "/layers", "-cache-dir", "/cache", "-launch-cache", "/launch-cache", "-daemon", "docker.io/library/my-application:latest" ], + "Labels" : { + "author" : "spring-boot" + }, + "HostConfig" : { + "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache", "pack-cache-b35197ac41ea.launch:/launch-cache" ] + } +} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-detector.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-detector.json deleted file mode 100644 index fc545e72c9..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-detector.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/detector", "-app", "/workspace", "-platform", "/platform" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-exporter.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-exporter.json deleted file mode 100644 index 840eea6c66..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-exporter.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "User" : "root", - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/exporter", "-image", "docker.io/cloudfoundry/run", "-layers", "/layers", "-app", "/workspace", "-daemon", "-launch-cache", "/launch-cache", "-cache-dir", "/cache", "docker.io/library/my-application:latest" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.launch:/launch-cache", "pack-cache-b35197ac41ea.build:/cache" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-restorer.json b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-restorer.json deleted file mode 100644 index 6aab9fb629..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/resources/org/springframework/boot/buildpack/platform/build/lifecycle-restorer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "User" : "root", - "Image" : "pack.local/ephemeral-builder", - "Cmd" : [ "/lifecycle/restorer", "-cache-dir", "/cache", "-layers", "/layers" ], - "Labels" : { - "author" : "spring-boot" - }, - "HostConfig" : { - "Binds" : [ "/var/run/docker.sock:/var/run/docker.sock", "pack-layers-aaaaaaaaaa:/layers", "pack-app-aaaaaaaaaa:/workspace", "pack-cache-b35197ac41ea.build:/cache" ] - } -} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java index 3e434a1da4..921c45c17f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java @@ -89,14 +89,14 @@ class BootBuildImageIntegrationTests { } @TestTemplate - void buildsImageWithV2Builder() throws IOException { + void buildsImageWithCustomBuilder() throws IOException { writeMainClass(); writeLongNameResource(); BuildResult result = this.gradleBuild.build("bootBuildImage"); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - assertThat(result.getOutput()).contains("example/test-image-v2"); - assertThat(result.getOutput()).contains("paketo-buildpacks/builder:base-platform-api-0.2"); - ImageReference imageReference = ImageReference.of(ImageName.of("example/test-image-v2")); + assertThat(result.getOutput()).contains("example/test-image-custom"); + assertThat(result.getOutput()).contains("paketo-buildpacks/builder:full-cf-platform-api-0.3"); + ImageReference imageReference = ImageReference.of(ImageName.of("example/test-image-custom")); try (GenericContainer container = new GenericContainer<>(imageReference.toString())) { container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start(); } @@ -109,12 +109,12 @@ class BootBuildImageIntegrationTests { void buildsImageWithCommandLineOptions() throws IOException { writeMainClass(); writeLongNameResource(); - BuildResult result = this.gradleBuild.build("bootBuildImage", "--imageName=example/test-image-v2", - "--builder=gcr.io/paketo-buildpacks/builder:base-platform-api-0.2"); + BuildResult result = this.gradleBuild.build("bootBuildImage", "--imageName=example/test-image-cmd", + "--builder=gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3"); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - assertThat(result.getOutput()).contains("example/test-image-v2"); - assertThat(result.getOutput()).contains("paketo-buildpacks/builder:base-platform-api-0.2"); - ImageReference imageReference = ImageReference.of(ImageName.of("example/test-image-v2")); + assertThat(result.getOutput()).contains("example/test-image-cmd"); + assertThat(result.getOutput()).contains("paketo-buildpacks/builder:full-cf-platform-api-0.3"); + ImageReference imageReference = ImageReference.of(ImageName.of("example/test-image-cmd")); try (GenericContainer container = new GenericContainer<>(imageReference.toString())) { container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start(); } @@ -129,7 +129,7 @@ class BootBuildImageIntegrationTests { writeLongNameResource(); BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage"); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED); - assertThat(result.getOutput()).contains("Builder lifecycle 'builder' failed with status code"); + assertThat(result.getOutput()).containsPattern("Builder lifecycle '.*' failed with status code"); } private void writeMainClass() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithV2Builder.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithCustomBuilder.gradle similarity index 57% rename from spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithV2Builder.gradle rename to spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithCustomBuilder.gradle index 3af45dd5b3..bf3cecec27 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithV2Builder.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-buildsImageWithCustomBuilder.gradle @@ -7,6 +7,6 @@ sourceCompatibility = '1.8' targetCompatibility = '1.8' bootBuildImage { - imageName = "example/test-image-v2" - builder = "gcr.io/paketo-buildpacks/builder:base-platform-api-0.2" + imageName = "example/test-image-custom" + builder = "gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3" } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java index 377c3fc6b5..62c41cd9d5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java @@ -94,11 +94,11 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests { mavenBuild.project("build-image").goals("package") .systemProperty("spring-boot.build-image.imageName", "example.com/test/cmd-property-name:v1") .systemProperty("spring-boot.build-image.builder", - "gcr.io/paketo-buildpacks/builder:base-platform-api-0.2") + "gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3") .execute((project) -> { assertThat(buildLog(project)).contains("Building image") .contains("example.com/test/cmd-property-name:v1") - .contains("paketo-buildpacks/builder:base-platform-api-0.2") + .contains("paketo-buildpacks/builder:full-cf-platform-api-0.3") .contains("Successfully built image"); ImageReference imageReference = ImageReference.of("example.com/test/cmd-property-name:v1"); try (GenericContainer container = new GenericContainer<>(imageReference.toString())) { @@ -111,10 +111,10 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests { } @TestTemplate - void whenBuildImageIsInvokedWithV2BuilderImage(MavenBuild mavenBuild) { - mavenBuild.project("build-image-v2-builder").goals("package").execute((project) -> { + void whenBuildImageIsInvokedWithCustomBuilderImage(MavenBuild mavenBuild) { + mavenBuild.project("build-image-custom-builder").goals("package").execute((project) -> { assertThat(buildLog(project)).contains("Building image") - .contains("paketo-buildpacks/builder:base-platform-api-0.2") + .contains("paketo-buildpacks/builder:full-cf-platform-api-0.3") .contains("docker.io/library/build-image-v2-builder:0.0.1.BUILD-SNAPSHOT") .contains("Successfully built image"); ImageReference imageReference = ImageReference @@ -132,7 +132,7 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests { void failsWhenBuilderFails(MavenBuild mavenBuild) { mavenBuild.project("build-image-builder-error").goals("package") .executeAndFail((project) -> assertThat(buildLog(project)).contains("Building image") - .contains("Builder lifecycle 'builder' failed with status code")); + .containsPattern("Builder lifecycle '.*' failed with status code")); } private void writeLongNameResource(File project) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v2-builder/pom.xml b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/pom.xml similarity index 92% rename from spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v2-builder/pom.xml rename to spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/pom.xml index 7ae145d180..b246fc61bb 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v2-builder/pom.xml +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/pom.xml @@ -23,7 +23,7 @@ - gcr.io/paketo-buildpacks/builder:base-platform-api-0.2 + gcr.io/paketo-buildpacks/builder:full-cf-platform-api-0.3 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v2-builder/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/src/main/java/org/test/SampleApplication.java similarity index 100% rename from spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-v2-builder/src/main/java/org/test/SampleApplication.java rename to spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/build-image-custom-builder/src/main/java/org/test/SampleApplication.java