Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Make an image built from a Dockerfile usable with modules

オープン
#1,551 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, typescript
領域
devtools

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
2.6k
フォーク
274
平均マージ
1日 14時間
マージ済み PR(30日)
44

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testcontainers/testcontainers-node のほかの issue

testcontainers/testcontainers-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。