Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Make an image built from a Dockerfile usable with modules

Đang mở
#1,551 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, typescript
Lĩnh vực
devtools

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
2.6k
Fork
274
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
44

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-node

Tất cả issue của testcontainers/testcontainers-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.