Add support for build workspace option when building images
Closes gh-37478
This commit is contained in:
@@ -233,6 +233,22 @@ class BuildRequestTests {
|
||||
.withMessage("Tags must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void withBuildWorkspaceVolumeAddsWorkspace() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
BuildRequest withWorkspace = request.withBuildWorkspace(Cache.volume("build-workspace"));
|
||||
assertThat(request.getBuildWorkspace()).isNull();
|
||||
assertThat(withWorkspace.getBuildWorkspace()).isEqualTo(Cache.volume("build-workspace"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void withBuildWorkspaceBindAddsWorkspace() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
BuildRequest withWorkspace = request.withBuildWorkspace(Cache.bind("/tmp/build-workspace"));
|
||||
assertThat(request.getBuildWorkspace()).isNull();
|
||||
assertThat(withWorkspace.getBuildWorkspace()).isEqualTo(Cache.bind("/tmp/build-workspace"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void withBuildVolumeCacheAddsCache() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
|
||||
@@ -211,7 +211,8 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
BuildRequest request = getTestRequest().withBuildCache(Cache.volume("build-volume"))
|
||||
BuildRequest request = getTestRequest().withBuildWorkspace(Cache.volume("work-volume"))
|
||||
.withBuildCache(Cache.volume("build-volume"))
|
||||
.withLaunchCache(Cache.volume("launch-volume"));
|
||||
createLifecycle(request).execute();
|
||||
assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-cache-volumes.json"));
|
||||
@@ -223,7 +224,8 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
BuildRequest request = getTestRequest().withBuildCache(Cache.bind("/tmp/build-cache"))
|
||||
BuildRequest request = getTestRequest().withBuildWorkspace(Cache.bind("/tmp/work"))
|
||||
.withBuildCache(Cache.bind("/tmp/build-cache"))
|
||||
.withLaunchCache(Cache.bind("/tmp/launch-cache"));
|
||||
createLifecycle(request).execute();
|
||||
assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-cache-bind-mounts.json"));
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
"HostConfig": {
|
||||
"Binds": [
|
||||
"/var/run/docker.sock:/var/run/docker.sock",
|
||||
"pack-layers-aaaaaaaaaa:/layers",
|
||||
"pack-app-aaaaaaaaaa:/workspace",
|
||||
"/tmp/work-layers:/layers",
|
||||
"/tmp/work-app:/workspace",
|
||||
"/tmp/build-cache:/cache",
|
||||
"/tmp/launch-cache:/launch-cache"
|
||||
],
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
"HostConfig": {
|
||||
"Binds": [
|
||||
"/var/run/docker.sock:/var/run/docker.sock",
|
||||
"pack-layers-aaaaaaaaaa:/layers",
|
||||
"pack-app-aaaaaaaaaa:/workspace",
|
||||
"work-volume-layers:/layers",
|
||||
"work-volume-app:/workspace",
|
||||
"build-volume:/cache",
|
||||
"launch-volume:/launch-cache"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user