Image
Represents an image definition for a Daytona sandbox.
Do not construct this class directly. Instead use one of its static factory methods,
such as Image.base(), Image.debianSlim() or Image.fromDockerfile().
Accessors
contextList
Get Signature
get contextList(): Context[]Returns
Context[]
The list of context files to be added to the image.
dockerfile
Get Signature
get dockerfile(): stringReturns:
string- The Dockerfile content.
Methods
base()
static base(image: string): ImageCreates an Image from an existing base image.
Parameters:
imagestring - The base image to use.
Returns:
Image- The Image instance.
Example:
const image = Image.base('python:3.12-slim-bookworm')debianSlim()
static debianSlim(pythonVersion?: "3.9" | "3.10" | "3.11" | "3.12" | "3.13"): ImageCreates a Debian slim image based on the official Python Docker image.
Parameters:
pythonVersion?The Python version to use. -"3.9"|"3.10"|"3.11"|"3.12"|"3.13"
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')fromDockerfile()
static fromDockerfile(path: string): ImageCreates an Image from an existing Dockerfile.
Parameters:
pathstring - The path to the Dockerfile.
Returns:
Image- The Image instance.
Example:
const image = Image.fromDockerfile('Dockerfile')addLocalDir()
addLocalDir(localPath: string, remotePath: string): ImageAdds a local directory to the image.
Parameters:
localPathstring - The path to the local directory.remotePathstring - The path of the directory in the image.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .addLocalDir('src', '/home/daytona/src')addLocalFile()
addLocalFile(localPath: string, remotePath: string): ImageAdds a local file to the image.
Parameters:
localPathstring - The path to the local file.remotePathstring - The path of the file in the image.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .addLocalFile('requirements.txt', '/home/daytona/requirements.txt')cmd()
cmd(cmd: string[]): ImageSets the default command for the image.
Parameters:
cmdstring[] - The command to set as the default command.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .cmd(['/bin/bash'])dockerfileCommands()
dockerfileCommands(dockerfileCommands: string[], contextDir?: string): ImageExtends an image with arbitrary Dockerfile-like commands.
Parameters:
dockerfileCommandsstring[] - The commands to add to the Dockerfile.contextDir?string - The path to the context directory.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .dockerfileCommands(['RUN echo "Hello, world!"'])entrypoint()
entrypoint(entrypointCommands: string[]): ImageSets the entrypoint for the image.
Parameters:
entrypointCommandsstring[] - The commands to set as the entrypoint.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .entrypoint(['/bin/bash'])env()
env(envVars: Record<string, string>): ImageSets environment variables in the image.
Parameters:
envVarsRecord<string, string> - The environment variables to set.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .env({ FOO: 'bar' })pipInstall()
pipInstall(packages: string | string[], options?: PipInstallOptions): ImageAdds commands to install packages using pip.
Parameters:
packagesThe packages to install. -string|string[]options?PipInstallOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })pipInstallFromPyproject()
pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): ImageInstalls dependencies from a pyproject.toml file.
Parameters:
pyprojectTomlstring - The path to the pyproject.toml file.options?PyprojectOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })pipInstallFromRequirements()
pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): ImageInstalls dependencies from a requirements.txt file.
Parameters:
requirementsTxtstring - The path to the requirements.txt file.options?PipInstallOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })runCommands()
runCommands(...commands: (string | string[])[]): ImageRuns commands in the image.
Parameters:
commands…(string | string[])[] - The commands to run.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .runCommands( 'echo "Hello, world!"', ['bash', '-c', 'echo Hello, world, again!'] )workdir()
workdir(dirPath: string): ImageSets the working directory in the image.
Parameters:
dirPathstring - The path to the working directory.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .workdir('/home/daytona')Context
Represents a context file to be added to the image.
Properties:
archivePathstring - The path inside the archive file in object storage.sourcePathstring - The path to the source file or directory.
PipInstallOptions
Options for the pip install command.
Properties:
extraIndexUrls?string[] - The extra index URLs to use for the pip install command.extraOptions?string - The extra options to use for the pip install command. Given string is passed directly to the pip install command.findLinks?string[] - The find-links to use for the pip install command.indexUrl?string - The index URL to use for the pip install command.pre?boolean - Whether to install pre-release versions.
Extended by
PyprojectOptions
PyprojectOptions
Options for the pip install command from a pyproject.toml file.
Properties:
extraIndexUrls?string[] - The extra index URLs to use for the pip install command.- Inherited from:
PipInstallOptions.extraIndexUrls
- Inherited from:
extraOptions?string - The extra options to use for the pip install command. Given string is passed directly to the pip install command.- Inherited from:
PipInstallOptions.extraOptions
- Inherited from:
findLinks?string[] - The find-links to use for the pip install command.- Inherited from:
PipInstallOptions.findLinks
- Inherited from:
indexUrl?string - The index URL to use for the pip install command.- Inherited from:
PipInstallOptions.indexUrl
- Inherited from:
optionalDependencies?string[] - The optional dependencies to install.pre?boolean - Whether to install pre-release versions.- Inherited from:
PipInstallOptions.pre
- Inherited from:
Extends:
PipInstallOptions