Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Make an image built from a Dockerfile usable with modules

Abierto
#1,551 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, typescript
Área
devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement minor

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 plain GenericContainer.

build(image?, options?) is awkward on its own terms:

  • The image name is positional and comes first, so setting deleteOnExit means supplying an image name too.
  • BuildOptions is { 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.ts
  • fromDockerfile in packages/testcontainers/src/generic-container/generic-container.ts

Notes

  • Java's GenericContainer has a constructor that takes a Future<String> image, which is how new 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.
Lenguaje dominante
TypeScript
Estrellas
2.6k
Forks
274
Merge medio
1 d 14 h
PR fusionados (30 d)
44

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testcontainers/testcontainers-node

Todos los issues de testcontainers/testcontainers-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.