Make an image built from a Dockerfile usable with modules
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, typescript
- Domain
- devtools
Research direction
Read packages/testcontainers/src/generic-container/generic-container-builder.ts and the fromDockerfile implementation in packages/testcontainers/src/generic-container/generic-container.ts; check issues #1527 and #1518 for overlapping changes. Trace how the builder names and returns an image, then inspect container construction and types. Done when the options object and build result work as described, existing GenericContainer.fromDockerfile(...).build() remains usable, and the listed API cases type-check.
Written by the indexing model from the issue text.
Description
What happens
GenericContainer.fromDockerfile(context).build() resolves to a GenericContainer. The image it built is only reachable through that one object:
- The image name is held in a protected field, so it cannot be read back.
- A module cannot use it. To run a custom Postgres image with
PostgreSqlContainer, the image has to be given an explicit name and that name repeated:
await GenericContainer.fromDockerfile(context).build("my-postgres:test", { deleteOnExit: true });
const container = await new PostgreSqlContainer("my-postgres:test").start();
PostgreSqlContainer.fromDockerfile(...)type-checks, because the static is inherited, but still returns a plainGenericContainer.
build(image?, options?) is awkward on its own terms:
- The image name is positional and comes first, so setting
deleteOnExitmeans supplying an image name too. BuildOptionsis{ deleteOnExit: boolean }with its only field required.- The builder class is named
GenericContainerBuilder, although what it builds is an image.
Expected
Building an image and choosing a container class are separate steps:
build()takes an options object,build({ image, deleteOnExit }).- A build result that exposes the image name, for example
const image = await ImageBuilder.fromDockerfile(context).build(); image.getName(). - Container constructors accept that result as well as a string, so
new PostgreSqlContainer(image)works. GenericContainer.fromDockerfile(...).build()keeps working.
Where
packages/testcontainers/src/generic-container/generic-container-builder.tsfromDockerfileinpackages/testcontainers/src/generic-container/generic-container.ts
Notes
- Java's
GenericContainerhas a constructor that takes aFuture<String>image, which is hownew GenericContainer(new ImageFromDockerfile()...)works: the build is a value passed to a container.
Dependencies
- Nothing blocks this. It can start now.
- Coordinate with #1527: both touch
GenericContainerBuilder(withBuildArgs). - Coordinate with #1518: for the positional
build(image, options)form.
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 290
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 22
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from testcontainers/testcontainers-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
testcontainers/testcontainers-node#1673 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
testcontainers/testcontainers-node#1539 ·
Maintainers usually reply within 4 days
-
Let `Wait.forListeningPorts()` wait on specific portsPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-node#1533 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
testcontainers/testcontainers-node#1531 ·
Maintainers usually reply within 4 days
-
Export the types used in public method signaturesPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-node#1528 ·
Maintainers usually reply within 4 days
All issues in testcontainers/testcontainers-node
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day