forked from testcontainers/testcontainers-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiStageBuildTest.java
28 lines (23 loc) · 949 Bytes
/
MultiStageBuildTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.testcontainers.containers;
import org.junit.Test;
import org.testcontainers.images.builder.ImageFromDockerfile;
import java.io.IOException;
import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
public class MultiStageBuildTest {
@Test
public void testDockerMultistageBuild() throws IOException, InterruptedException {
try (
GenericContainer<?> container = new GenericContainer<>(
new ImageFromDockerfile()
.withDockerfile(Paths.get("src/test/resources/Dockerfile-multistage"))
.withTarget("builder")
)
.withCommand("/bin/sh", "-c", "sleep 10")
) {
container.start();
assertThat(container.execInContainer("pwd").getStdout()).contains("/my-files");
assertThat(container.execInContainer("ls").getStdout()).contains("hello.txt");
}
}
}