Skip to main content
Build a local Docker image, or just its Docker build context, from a model directory. These commands run entirely locally: they shell out to the truss CLI (via ‘uv’) to generate the build context and to ‘docker’ to build the image. They need no authentication and make no Baseten API calls. ‘uv’ must be on PATH; ‘build’ also requires ‘docker’.

build

Generate the Docker build context for a model directory and build it into a local Docker image. The current directory is used by default; pass —dir to point at a model directory elsewhere. The build context is written to a temporary directory that is removed afterward unless —build-dir is given. Any arguments after ’—’ are passed through verbatim to ‘docker build’. If you supply your own —iidfile there, it is honored and used to report the image ID; otherwise one is injected internally.

Options

TEXT
Directory for the Docker build context. Defaults to a temp dir removed after the build.
TEXT
Enable a persistent apt/pip/uv build cache keyed by this id.
TEXT
default:"."
Model directory.
TEXT
Filter JSON output with a jq expression; implies —output json (or jsonl for streamed commands)
TEXT
default:"text"
Output formatOne of: text, json, jsonl, none
TEXT
Use a specific stored profile for this command, overriding BASETEN_PROFILE and the current profile
BOOL
Run the image’s container as root instead of the default non-root user.
TEXT
Image tag. Defaults to ‘model_name:latest’ from config.yaml.
TEXT
Run this truss executable instead of fetching one with uv, e.g. a virtualenv’s bin/truss. A value with no path separator is looked up on PATH, so ‘—truss-executable truss’ runs the truss you installed. Defaults to BASETEN_TRUSS_EXECUTABLE.
TEXT
Version of truss to fetch and run with ‘uv tool run’, e.g. 0.18.26. Defaults to BASETEN_TRUSS_VERSION, or the latest release. Mutually exclusive with —truss-executable.
BOOL
Enable verbose logging

Examples

Build the current directory into a local Docker image
Build another directory with a custom tag
Pass extra flags through to docker build

Filter output with --jq

Print the built image ID

Output

Text mode (--output text): Build progress from truss and docker is streamed to stderr. On success a one-line summary is printed to stdout. JSON mode (--output json): payload type cmd.ModelImageBuildResult. Under —output json, stdout is the {image_id, tag} result. image_id is empty when it cannot be resolved (e.g. a custom buildx builder that does not write the iidfile).

prepare

Generate the Docker build context (Dockerfile and supporting files) for a model directory into —build-dir, without building an image. The current directory is used by default; pass —dir to point at a model directory elsewhere. The resulting directory is self-contained and can be built with ‘docker build build-dir’.

Options

TEXT
required
Directory for the Docker build context. Created if absent and kept.
TEXT
Enable a persistent apt/pip/uv build cache keyed by this id.
TEXT
default:"."
Model directory.
TEXT
Filter JSON output with a jq expression; implies —output json (or jsonl for streamed commands)
TEXT
default:"text"
Output formatOne of: text, json, jsonl, none
TEXT
Use a specific stored profile for this command, overriding BASETEN_PROFILE and the current profile
BOOL
Run the image’s container as root instead of the default non-root user.
TEXT
Run this truss executable instead of fetching one with uv, e.g. a virtualenv’s bin/truss. A value with no path separator is looked up on PATH, so ‘—truss-executable truss’ runs the truss you installed. Defaults to BASETEN_TRUSS_EXECUTABLE.
TEXT
Version of truss to fetch and run with ‘uv tool run’, e.g. 0.18.26. Defaults to BASETEN_TRUSS_VERSION, or the latest release. Mutually exclusive with —truss-executable.
BOOL
Enable verbose logging

Examples

Write the current directory’s build context to ./ctx

Filter output with --jq

Print the generated Dockerfile path

Output

Text mode (--output text): Progress from truss is streamed to stderr. On success a one-line summary is printed to stdout. JSON mode (--output json): payload type cmd.ModelImagePrepareResult. Under —output json, stdout is the {build_dir, dockerfile} result with absolute paths.