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.debian_slim(), or Image.from_dockerfile().
Constructors
new Image()
def initialize(dockerfile:, context_list:)Parameters:
dockerfileString, nil - The Dockerfile contentcontext_listArray<Context> - List of context files
Returns:
Image- a new instance of Image
Methods
dockerfile()
def dockerfile()Returns:
String, nil- The generated Dockerfile for the image
context_list()
def context_list()Returns:
Array\<Context\>- List of context files for the image
pip_install()
def pip_install(*packages, find_links:, index_url:, extra_index_urls:, pre:, extra_options:)Adds commands to install packages using pip
Parameters:
packagesArray<String> - The packages to installfind_linksArray<String>, nil - The find-links to useindex_urlString, nil - The index URL to useextra_index_urlsArray<String>, nil - The extra index URLs to usepreBoolean - Whether to install pre-release packagesextra_optionsString - Additional options to pass to pip
Returns:
Image- The image with the pip install commands added
Examples:
image = Image.debian_slim("3.12").pip_install("requests", "pandas")pip_install_from_requirements()
def pip_install_from_requirements(requirements_txt, find_links:, index_url:, extra_index_urls:, pre:, extra_options:)Installs dependencies from a requirements.txt file
Parameters:
requirements_txtString - The path to the requirements.txt filefind_linksArray<String>, nil - The find-links to useindex_urlString, nil - The index URL to useextra_index_urlsArray<String>, nil - The extra index URLs to usepreBoolean - Whether to install pre-release packagesextra_optionsString - Additional options to pass to pip
Returns:
Image- The image with the pip install commands added
Raises:
Sdk:Error- If the requirements file does not exist
Examples:
image = Image.debian_slim("3.12").pip_install_from_requirements("requirements.txt")pip_install_from_pyproject()
def pip_install_from_pyproject(pyproject_toml, optional_dependencies:, find_links:, index_url:, extra_index_url:, pre:, extra_options:)Installs dependencies from a pyproject.toml file
Parameters:
pyproject_tomlString - The path to the pyproject.toml fileoptional_dependenciesArray<String> - The optional dependencies to installfind_linksString, nil - The find-links to useindex_urlString, nil - The index URL to useextra_index_urlString, nil - The extra index URL to usepreBoolean - Whether to install pre-release packagesextra_optionsString - Additional options to pass to pip
Returns:
Image- The image with the pip install commands added
Raises:
Sdk:Error- If pyproject.toml parsing is not supported
Examples:
image = Image.debian_slim("3.12").pip_install_from_pyproject("pyproject.toml", optional_dependencies: ["dev"])add_local_file()
def add_local_file(local_path, remote_path)Adds a local file to the image
Parameters:
local_pathString - The path to the local fileremote_pathString - The path to the file in the image
Returns:
Image- The image with the local file added
Examples:
image = Image.debian_slim("3.12").add_local_file("package.json", "/home/daytona/package.json")add_local_dir()
def add_local_dir(local_path, remote_path)Adds a local directory to the image
Parameters:
local_pathString - The path to the local directoryremote_pathString - The path to the directory in the image
Returns:
Image- The image with the local directory added
Examples:
image = Image.debian_slim("3.12").add_local_dir("src", "/home/daytona/src")run_commands()
def run_commands(*commands)Runs commands in the image
Parameters:
commandsArray<String> - The commands to run
Returns:
Image- The image with the commands added
Examples:
image = Image.debian_slim("3.12").run_commands('echo "Hello, world!"', 'echo "Hello again!"')env()
def env(env_vars)Sets environment variables in the image
Parameters:
env_varsHash<String, String> - The environment variables to set
Returns:
Image- The image with the environment variables added
Raises:
Sdk:Error-
Examples:
image = Image.debian_slim("3.12").env({"PROJECT_ROOT" => "/home/daytona"})workdir()
def workdir(path)Sets the working directory in the image
Parameters:
pathString - The path to the working directory
Returns:
Image- The image with the working directory added
Examples:
image = Image.debian_slim("3.12").workdir("/home/daytona")entrypoint()
def entrypoint(entrypoint_commands)Sets the entrypoint for the image
Parameters:
entrypoint_commandsArray<String> - The commands to set as the entrypoint
Returns:
Image- The image with the entrypoint added
Examples:
image = Image.debian_slim("3.12").entrypoint(["/bin/bash"])cmd()
def cmd(cmd)Sets the default command for the image
Parameters:
cmdArray<String> - The commands to set as the default command
Returns:
Image- The image with the default command added
Examples:
image = Image.debian_slim("3.12").cmd(["/bin/bash"])dockerfile_commands()
def dockerfile_commands(dockerfile_commands, context_dir:)Adds arbitrary Dockerfile-like commands to the image
Parameters:
dockerfile_commandsArray<String> - The commands to add to the Dockerfilecontext_dirString, nil - The path to the context directory
Returns:
Image- The image with the Dockerfile commands added
Examples:
image = Image.debian_slim("3.12").dockerfile_commands(["RUN echo 'Hello, world!'"])