コンテンツにスキップ

Image

Daytona のサンドボックス用イメージ定義を表します。 このクラスを直接インスタンス化しないでください。代わりに Image.base()Image.debianSlim()Image.fromDockerfile() などの静的ファクトリメソッドを使用してください。

Accessors

contextList

Get Signature
get contextList(): Context[]
Returns

Context[]

イメージに追加されるコンテキストファイルの一覧。


dockerfile

Get Signature
get dockerfile(): string

Returns:

  • string - Dockerfile の内容。

Methods

base()

static base(image: string): Image

既存のベースイメージから Image を作成します。

Parameters:

  • image string - 使用するベースイメージ。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image.base('python:3.12-slim-bookworm')

debianSlim()

static debianSlim(pythonVersion?: "3.9" | "3.10" | "3.11" | "3.12" | "3.13"): Image

公式の Python Docker イメージに基づく Debian slim イメージを作成します。

Parameters:

  • pythonVersion? 使用する Python のバージョン。 - "3.9" | "3.10" | "3.11" | "3.12" | "3.13"

Returns:

  • Image - Image インスタンス。

Example:

const image = Image.debianSlim('3.12')

fromDockerfile()

static fromDockerfile(path: string): Image

既存の Dockerfile から Image を作成します。

Parameters:

  • path string - Dockerfile へのパス。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image.fromDockerfile('Dockerfile')

addLocalDir()

addLocalDir(localPath: string, remotePath: string): Image

ローカルディレクトリをイメージに追加します。

Parameters:

  • localPath string - ローカルディレクトリのパス。
  • remotePath string - イメージ内のディレクトリのパス。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image
.debianSlim('3.12')
.addLocalDir('src', '/home/daytona/src')

addLocalFile()

addLocalFile(localPath: string, remotePath: string): Image

ローカルファイルをイメージに追加します。

Parameters:

  • localPath string - ローカルファイルのパス。
  • remotePath string - イメージ内のファイルのパス。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image
.debianSlim('3.12')
.addLocalFile('requirements.txt', '/home/daytona/requirements.txt')

cmd()

cmd(cmd: string[]): Image

イメージのデフォルトコマンドを設定します。

Parameters:

  • cmd string[] - デフォルトとして設定するコマンド。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image
.debianSlim('3.12')
.cmd(['/bin/bash'])

dockerfileCommands()

dockerfileCommands(dockerfileCommands: string[], contextDir?: string): Image

任意の Dockerfile 形式のコマンドでイメージを拡張します。

Parameters:

  • dockerfileCommands string[] - Dockerfile に追加するコマンド。
  • contextDir? string - コンテキストディレクトリのパス。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image
.debianSlim('3.12')
.dockerfileCommands(['RUN echo "Hello, world!"'])

entrypoint()

entrypoint(entrypointCommands: string[]): Image

イメージのエントリーポイントを設定します。

Parameters:

  • entrypointCommands string[] - エントリーポイントとして設定するコマンド。

Returns:

  • Image - Image インスタンス。

Example:

const image = Image
.debianSlim('3.12')
.entrypoint(['/bin/bash'])

env()

env(envVars: Record<string, string>): Image

イメージ内の環境変数を設定します。

パラメーター:

  • envVars Record<string, string> - 設定する環境変数。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image
.debianSlim('3.12')
.env({ FOO: 'bar' })

pipInstall()

pipInstall(packages: string | string[], options?: PipInstallOptions): Image

pip を使用してパッケージをインストールするコマンドを追加します。

パラメーター:

  • packages インストールするパッケージ - string | string[]
  • options? PipInstallOptions - pip インストールコマンドのオプション。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })

pipInstallFromPyproject()

pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): Image

pyproject.toml ファイルから依存関係をインストールします。

パラメーター:

  • pyprojectToml string - pyproject.toml ファイルのパス。
  • options? PyprojectOptions - pip インストールコマンドのオプション。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image.debianSlim('3.12')
image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })

pipInstallFromRequirements()

pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): Image

requirements.txt ファイルから依存関係をインストールします。

パラメーター:

  • requirementsTxt string - requirements.txt ファイルのパス。
  • options? PipInstallOptions - pip インストールコマンドのオプション。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image.debianSlim('3.12')
image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })

runCommands()

runCommands(...commands: (string | string[])[]): Image

イメージ内でコマンドを実行します。

パラメーター:

  • commands …(string | string[])[] - 実行するコマンド。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image
.debianSlim('3.12')
.runCommands(
'echo "Hello, world!"',
['bash', '-c', 'echo Hello, world, again!']
)

workdir()

workdir(dirPath: string): Image

イメージ内の作業ディレクトリを設定します。

パラメーター:

  • dirPath string - 作業ディレクトリのパス。

戻り値:

  • Image - Image インスタンス。

例:

const image = Image
.debianSlim('3.12')
.workdir('/home/daytona')

コンテキスト

イメージに追加するコンテキストファイルを表します。

プロパティ:

  • archivePath string - オブジェクトストレージ内のアーカイブの内部パス。
  • sourcePath string - ソースファイルまたはディレクトリへのパス。

PipInstallOptions

pip install コマンド用のオプション。

プロパティ:

  • extraIndexUrls? string[] - pip install コマンドで使用する追加のインデックス URL。
  • extraOptions? string - pip install コマンドで使用する追加オプション。指定した文字列がそのまま pip install コマンドに渡されます。
  • findLinks? string[] - pip install コマンドで使用する find-links。
  • indexUrl? string - pip install コマンドで使用するインデックス URL。
  • pre? boolean - プレリリース版をインストールするかどうか。

により拡張

  • PyprojectOptions

PyprojectOptions

pyproject.toml からの pip install コマンド用オプション。

プロパティ:

  • extraIndexUrls? string[] - pip install コマンドで使用する追加のインデックス URL。
    • 継承元: PipInstallOptions.extraIndexUrls
  • extraOptions? string - pip install コマンドに渡す追加オプション。指定した文字列がそのまま pip install コマンドに渡されます。
    • 継承元: PipInstallOptions.extraOptions
  • findLinks? string[] - pip install コマンドで使用する find-links。
    • 継承元: PipInstallOptions.findLinks
  • indexUrl? string - pip install コマンドで使用するインデックス URL。
    • 継承元: PipInstallOptions.indexUrl
  • optionalDependencies? string[] - 任意でインストールする依存関係。
  • pre? boolean - プレリリース版をインストールするかどうか。
    • 継承元: PipInstallOptions.pre

継承:

  • PipInstallOptions