Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An extension to use pack and buildpacks to build container images (#14)
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Use Pack to build container images | ||
|
||
Build container images using [pack](https://buildpacks.io/docs/install-pack/) and [buildpacks](https://buildpacks.io/). | ||
|
||
## Usage | ||
|
||
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. | ||
|
||
```python | ||
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 built | ||
* `path`: path to application directory, defaults to the current working directory | ||
* `builder`: builder image, defaults to gcr.io/paketo-buildpacks/builder:base | ||
|
||
The function also supports all of the properties of [`custom_build`](https://docs.tilt.dev/api.html#api.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](https://paketo.io/) one, | ||
you would do the following: | ||
|
||
```python | ||
pack( | ||
'example-image', | ||
builder='gcr.io/paketo-buildpacks/builder:tiny' | ||
) | ||
``` | ||
|
||
## Requirements | ||
|
||
* The `pack` binary must be on your path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- mode: Python -*- | ||
|
||
def pack(name, path=".", builder="gcr.io/paketo-buildpacks/builder:base", **kwargs): | ||
""" | ||
Build a container image using pack and buildpacks. | ||
Args: | ||
name: name of the image to build | ||
path: path to application directory, defaults to current working directory | ||
builder: builder image, defaults to gcr.io/paketo-buildpacks/builder:base | ||
**kwargs: will be passed to the underlying `custom_build` call | ||
""" | ||
custom_build( | ||
name, | ||
"pack build $EXPECTED_REF -p %s --builder %s" % (path, builder), | ||
[path], | ||
**kwargs | ||
) |