testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
8.04k stars 1.66k forks source link

`ImageFromDockerfile` not working when `withFileFromFile` and `withDockerfile` are used at the same time #4693

Open MarconZet opened 2 years ago

MarconZet commented 2 years ago

Issue

This works as expected

new ImageFromDockerfile(imageName, true)
    .withFileFromFile("Dockerfile", new File("dev/keycloak/Dockerfile"))
    .withFileFromFile("dev/keycloak/sbt-project", new File("dev/keycloak/sbt-project"))

while this fails to create image and deadlocks on PipedInputStream#awaitSpace()

new ImageFromDockerfile(imageName, true)
    .withDockerfile(new File("dev/keycloak/Dockerfile").toPath)
    .withFileFromFile("dev/keycloak/sbt-project", new File("dev/keycloak/sbt-project"))

Expected result

At least some kind of warning or exception

kiview commented 1 month ago

Since this unexpected behavior re-surfaces time and time again, I think the issue here is, that withDockerfile() generally does not honor the user specified context. I am not sure if this originates in our upstream integration with docker-java, I did not find the issue in our code on a first glance.