Skip to content

Accept an in-memory Compose definition #1573

Open

Description

@cristianrgreco

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestminorBackward compatible functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions