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

Parameters:
  • 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:

None

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
api.helm(pathToChartDir)

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.

Parameters:
  • 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:

None

api.k8s_yaml(yaml)

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
api.kustomize(pathToDir)

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

Return type:Blob
api.local(cmd)

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

Return type:Blob
api.local_git_repo(path)

Creates a repo from the git repo at path.

Return type:Repo
api.read_file(file_path)

Reads file and returns its contents.

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