testcontainers / testcontainers/testcontainers-java
Creating Testcontainer from custom image doesn't work
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
I'm writing tests for my room-service and i need the image-service because the room-service has dependencies on the image-service. this is my file tree:
+---image-service
¦ ¦ Dockerfile
¦ ¦ pom.xml
¦ ¦
¦ +---src
¦ ¦ +---main
¦ ¦ ¦ +---java
¦ ¦ ¦ +---resources
¦ ¦ +---test
¦ ¦ +---java
¦ ¦ +---de
¦ ¦ +---fh
¦ ¦ ApplicationTest.java
+---room-service
¦ ¦ Dockerfile
¦ ¦ pom.xml
¦ ¦
¦ +---src
¦ ¦ +---main
¦ ¦ ¦ +---java
¦ ¦ ¦ +---resources
¦ ¦ +---test
¦ ¦ +---java
¦ ¦ ¦ +---de.fh
¦ ¦ ¦ ApplicationTest.java
¦ ¦ ¦
¦ ¦ +---resources
¦ ¦ application.yml
In my ApplicationTest in room-service I try to create a generic container from the dockerfile in /image-service/Dockerfile:
@BeforeClass
public static void init() {
eurekaContainer = new GenericContainer(new ImageFromDockerfile("image-service")
.withFileFromFile("./image-service", new File("../image-service/Dockerfile")));
eurekaContainer.start();
}
I couldn't find any use cases like this in the documentation.
Am I using the wrong method? Are any of the paths I used wrong?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with room-service/src/test/java/.../ApplicationTest.java and the referenced image-service/Dockerfile. Check how ImageFromDockerfile and withFileFromFile resolve paths and run the room-service test; done means the custom image builds and the container starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- devops, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100