use of org.testcontainers.images.builder.ImageFromDockerfile in project testcontainers-java by testcontainers.
the class DockerfileTest method customizableImage.
@Test
public void customizableImage() {
ImageFromDockerfile image = new ImageFromDockerfile() {
@Override
protected void configure(BuildImageCmd buildImageCmd) {
super.configure(buildImageCmd);
List<String> dockerfile = Arrays.asList("FROM alpine:3.2", "RUN echo 'hello from Docker build process'", "CMD yes");
withFileFromString("Dockerfile", String.join("\n", dockerfile));
buildImageCmd.withNoCache(true);
}
};
verifyImage(image);
}
use of org.testcontainers.images.builder.ImageFromDockerfile in project testcontainers-java by testcontainers.
the class DirectoryTarResourceTest method simpleRecursiveClasspathResourceTest.
@Test
public void simpleRecursiveClasspathResourceTest() throws TimeoutException {
// This test combines the copying of classpath resources from JAR files with the recursive TAR approach, to allow JARed classpath resources to be copied in to an image
WaitingConsumer wait = new WaitingConsumer();
final ToStringConsumer toString = new ToStringConsumer();
GenericContainer container = new GenericContainer(new ImageFromDockerfile().withDockerfileFromBuilder(builder -> builder.from("alpine:3.3").copy("/tmp/foo", "/foo").cmd("ls -lRt /foo").build()).withFileFromClasspath("/tmp/foo", // here we use /org/junit as a directory that really should exist on the classpath
"/recursive/dir")).withStartupCheckStrategy(new OneShotStartupCheckStrategy()).withLogConsumer(wait.andThen(toString));
container.start();
wait.waitUntilEnd(60, TimeUnit.SECONDS);
final String results = toString.toUtf8String();
// ExternalResource.class is known to exist in a subdirectory of /org/junit so should be successfully copied in
assertTrue("The container has a file that was copied in via a recursive copy from a JAR resource", results.contains("content.txt"));
}
Aggregations