Accept an in-memory Compose definition

Open
#1,573 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
57/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, docker-compose, typescript
Domain
devtools, testing

Research direction

Start with packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts and the compose client files under packages/testcontainers/src/container-runtime/clients/compose/; trace how file paths reach the Compose command. Check how the client could pass a definition through -f -, and how a base directory would support relative paths. Done means callers can provide YAML text or an object and the resulting environment behaves like the file based version.

Written by the indexing model from the issue text.

Description

enhancement minor

What happens

new DockerComposeEnvironment(composeFilePath, composeFiles) needs compose files on disk. A test that wants to vary the definition (an image tag from a variable, an optional service, a generated port) has to write a temporary file and clean it up.

Expected

A Compose environment can be created from a definition held in memory, as YAML text or as an object:

await DockerComposeEnvironment.fromDefinition({
  services: {
    redis: { image: `redis:${version}`, ports: ["6379"] },
  },
}).up();

Everything else behaves as it does for a file.

Where

  • packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts
  • packages/testcontainers/src/container-runtime/clients/compose/

Notes

  • Go has WithStackReaders(readers...) next to WithStackFiles(files...).
  • Compose reads a definition from standard input with -f -, which avoids a temporary file if the client wrapper allows it.
  • Relative paths inside the definition need a base directory.

Dependencies

  • Nothing blocks this. It can start now.
  • Coordinate with #1561, #1540: all three change DockerComposeEnvironment's constructor or lookup.
Dominant language
TypeScript
Stars
2.7k
Forks
290
Avg merge
4d 1h
Merged PRs (30d)
22

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from testcontainers/testcontainers-node

All issues in testcontainers/testcontainers-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.