Image
classgworker_client.image.Image
Container image specification. Immutable — every method returns a new Image. Chains are evaluated top-to-bottom at deploy time to produce a Dockerfile. Share a base image across tasks to reuse the build cache.
Class
1class ImageMethods
base
1base(image: str = 'python:3.12-slim', python_version: str = '3.12') -> ImageStart a new image chain from a Docker Hub or registry image. python_version controls the Python interpreter used by pip_install steps.
pip_install
1pip_install(packages: str = ()) -> ImageInstall one or more Python packages with pip. Accepts the same specifiers as pip install (name, name==version, git+url, etc.).
pip_install_requirements
1pip_install_requirements(path: str | Path) -> ImageInstall packages listed in a requirements.txt file. The file is read at deploy time from the local filesystem relative to the project root.
pip_install_pyproject
1pip_install_pyproject(path: str | Path) -> ImageInstall the package defined in a pyproject.toml. Equivalent to `pip install -e .` from the given path.
system_install
1system_install(packages: str = ()) -> ImageInstall apt packages (Debian/Ubuntu base images only). Runs apt-get install -y without prompts.
run_commands
1run_commands(commands: str = ()) -> ImageRun arbitrary shell commands as root in the image build context. Each string is a separate RUN layer.
env
1env(vars: str = {}) -> ImageSet environment variables in the image (equivalent to Dockerfile ENV). Use for config that is not secret — for secrets, use Secret instead.
workdir
1workdir(path: str) -> ImageSet the working directory for subsequent commands and for the task at runtime. Equivalent to Dockerfile WORKDIR.
add_local_dir
1add_local_dir(local: str | Path, remote: str, ignore: Iterable[str] | None = None) -> ImageCopy a local directory into the image at remote. Patterns in ignore are excluded (gitignore syntax). The directory is snapshotted at deploy time.
add_local_file
1add_local_file(local: str | Path, remote: str) -> ImageCopy a single local file into the image at remote. The file is snapshotted at deploy time.
dockerfile_commands
1dockerfile_commands(commands: str = ()) -> ImageAppend raw Dockerfile instructions verbatim. Use only for directives not covered by the other methods (e.g. LABEL, ARG, EXPOSE).