Tiltfile API Reference

class api.Blob

The result of executing a command on your local system

class api.LocalPath

A path on disk

api.docker_build(ref, context, build_args={}, dockerfile='Dockerfile', dockerfile_contents='')

Builds a docker image.

Note that you can’t set both the dockerfile and dockerfile_contents arguments (will throw an error).

Example: docker_build('myregistry/myproj/backend', '/path/to/code') is roughly equivalent to the call docker build /path/to/code -t myregistry/myproj/backend

  • ref (str) – name for this image (e.g. ‘myproj/backend’ or ‘myregistry/myproj/backend’). If this image will be used in a k8s resource(s), this ref must match the spec.container.image param for that resource(s).
  • context (str) – path to use as the Docker build context.
  • build_args (Dict[str, str]) – build-time variables that are accessed like regular environment variables in the RUN instruction of the Dockerfile. See the Docker Build Arg documentation
  • dockerfile (Union[str, LocalPath]) – path to the Dockerfile to build (may be absolute, or relative to cwd)
  • dockerfile_contents (Union[str, Blob]) – raw contents of the Dockerfile to use for this build
Return type:


api.fast_build(img_name, dockerfile_path, entrypoint='')

Initiates a docker image build that supports add s and run s, and that uses a cache for subsequent builds.

See the fast build documentation.

Return type:FastBuild

Run helm template on a given directory that contains a chart and return the fully rendered YAML as a Blob

Return type:Blob
api.k8s_resource(name, yaml='', image='', port_forwards=[])

Creates a kubernetes resource that tilt can deploy using the specified image.

  • name (str) – What call this resource in the UI
  • yaml (Union[str, Blob]) – Optional YAML. If YAML, as a string or Blob is not passed we expect to be able to extract it from an existing resource.
  • image (str) – An optional Image. If the image is not passed, we expect to be able to extract it from an existing resource.
  • port_forwards (Union[str, int, List[int]]) – Local ports to connect to the pod. If no target port is specified, will use the first container port. Example values: 9000 (connect localhost:9000 to the default container port), ‘9000:8000’ (connect localhost:9000 to the container port 8000), [‘9000:8000’, ‘9001:8001’] (connect localhost:9000 and :9001 to the container ports 8000 and 8001, respectively).
Return type:



Call this with a path to a file that contains YAML, or with a Blob of YAML.

We will infer what (if any) of the k8s resources defined in your YAML correspond to Images defined elsewhere in your Tiltfile (matching based on the DockerImage ref and on pod selectors). Any remaining YAML is YAML that Tilt applies to your k8s cluster independently.

Parameters:yaml (Union[str, List[str], LocalPath, Blob]) – Path(s) to YAML or YAML as a Blob.
Return type:None

Run kustomize on a given directory and return the resulting YAML as a Blob

Return type:Blob

Runs cmd, waits for it to finish, and returns its stdout as a Blob

Return type:Blob

Creates a repo from the git repo at path.

Return type:Repo

Reads file and returns its contents.

Parameters:file_path (Union[str, LocalPath]) – Path to the file locally
Return type:Blob