Author: Gareth Rushgrove
Build container images using pack and buildpacks.
This extension adds the pack
function, which is used the same way as docker_build
to allow Tilt
to automatically build a container image with a known name. For instance the following example shows
building an image using the default builder and having that image automatically deployed to Kubernetes.
load('ext://pack', 'pack')
pack('example-image')
k8s_yaml('kubernetes.yaml')
k8s_resource('example-deployment', port_forwards=8000)
The pack
function can take a few arguments:
name
: name of the image to be builtpull_policy
: pull policy used by pack, defaults toif-not-present
path
: path to application directory, defaults to the current working directorybuilder
: builder image, defaults to gcr.io/paketo-buildpacks/builder:basedeps
: a list of dependencies, defaults topath
buildpacks
: a list of buildpacks to use. (list[str])env_vars
: a list of environment variables, defaults toBP_LIVE_RELOAD_ENABLED=true
(list[str])
The function also supports all of the properties of custom_build
so
you can ignore files, override the entrypoint or set live updates as usual.
For instance, if you want to use the tiny builder instead of the default Paketo one, you would do the following:
pack(
'example-image',
builder='gcr.io/paketo-buildpacks/builder:tiny'
)
See the test directory for an example that builds an Apache HTTPD server.
- Use the Tilt example repo
- Use the following
Tiltfile
# -*- mode: Python -*-
load('ext://pack', 'pack')
pack(
'example-java-image',
deps=['./bin/main'],
live_update = [
sync('./bin/main', '/workspace/BOOT-INF/classes'),
],
)
k8s_yaml('kubernetes.yaml')
k8s_resource('example-java', port_forwards=8000)
Then tilt up
. Modifications are live synced into the application container.
This example requires Visual Studio Code with the Java and Gradle extensions. VS Code will compile on save and put the compiled changes in ./bin/main
. Tilt then syncs those into the container. You will need to adjust the deps
and live_update
path if you're using a different IDE or building with Gradle directly where compiled artifacts are placed in a different location.
- Use the Tilt example repo
- Use the following
Tiltfile
# -*- mode: Python -*
load('ext://pack', 'pack')
pack(
'example-nodejs-image',
live_update = [
sync('./', '/workspace/'),
])
k8s_yaml('kubernetes.yaml')
k8s_resource('example-nodejs', port_forwards=8000)
Then tilt up
. Modifications are live synced into the application container.
- The
pack
binary must be on your path.