Package a buildpack

Learn how to package your buildpack for distribution using standard OCI registries.

0. Grab the sample repo

Before we start, let’s pull down a few buildpacks from our samples repo.

# clone the repo
git clone https://github.com/buildpacks/samples

1. Create a package.toml

We will need to create a package.toml file in order to tell pack where to find the dependencies of the buildpack being packaged.

touch package.toml

2. Specify your buildpack

Let’s start off by specifying the location of the buildpack we are packaging. In this example, we’re packaging the hello-universe.

package.toml:

[buildpack]
uri = "samples/buildpacks/hello-universe/"

3. Specify your dependent buildpacks

Next, by looking at the [[order]] of the hello-universe, we know that it depends on the hello-world and hello-moon buildpacks. We will need to declare the location of those dependencies as well.

package.toml:

[buildpack]
uri = "samples/buildpacks/hello-universe/"

[[dependencies]]
uri = "samples/buildpacks/hello-moon"

[[dependencies]]
image = "cnbs/sample-package:hello-world"

For more information about the configuration, see package.toml config.

4. Package your buildpack

Lastly, we’ll run the package-buildpack command to package the buildpack as an OCI image.

pack package-buildpack my-buildpack --package-config ./package.toml

Tip: You can verify that the image was created by running docker images.

That’s it! Your buildpack is now packaged for distribution.

You may now use standard docker push to host your buildpack on any OCI registry of your choosing.

Alternatively, you can run pack package-buildpack with --publish to publish it directly to the registry.