Let’s see a build that requires base image extension in order to succeed.
The buildpack opts-out of the build (exits with non-zero code) unless the
BP_EXT_DEMO environment variable is set.
BP_EXT_DEMO environment variable is set, the buildpack detects (exits with code
0), but doesn’t require any dependencies through a build plan unless the
BP_REQUIRES environment variable is set.
The buildpack tries to use
vim at build-time, and defines a launch process called
curl that runs
curl --version at runtime.
For now, it is necessary for the builder image to be pushed to an OCI registry for builds with image extensions to succeed.
For demo purposes, we will launch a local unauthenticated registry:
docker run -d --rm -p 5000:5000 registry:2
You can push the builder to any registry of your choice - just ensure that
docker login succeeds and replace
localhost:5000 in the following examples with your registry namespace -
Create the builder:
pack builder create localhost:5000/extensions-builder \ --config $PWD/samples/builders/alpine/builder.toml \ --publish
pack build (note that the “source” directory is effectively ignored in our example):
pack build hello-extensions \ --builder localhost:5000/extensions-builder \ --env BP_EXT_DEMO=1 \ --network host \ --path $PWD/samples/apps/java-maven \ --pull-policy always \ --verbose
--network host is necessary when publishing to a local registry.
You should see:
... [detector] ======== Results ======== [detector] pass: email@example.com [detector] pass: firstname.lastname@example.org [detector] pass: email@example.com [detector] pass: firstname.lastname@example.org [detector] Resolving plan... (try #1) [detector] skip: email@example.com provides unused vim [detector] skip: firstname.lastname@example.org provides unused curl [detector] skip: email@example.com provides unused cowsay [detector] 1 of 4 buildpacks participating [detector] samples/hello-extensions 0.0.1 ... [extender (build)] Running build command [extender (build)] ---> Hello Extensions Buildpack [extender (build)] /cnb/buildpacks/samples_hello-extensions/0.0.1/bin/build: line 6: vim: command not found [extender (build)] ERROR: failed to build: exit status 127
What happened: our builder doesn’t have
vim installed, so the
hello-extensions buildpack failed to build (as it
tries to run
vim --version in its
Even though there is a
samples/vim extension that passed detection (
pass: firstname.lastname@example.org), because
hello-extensions buildpack didn’t require
vim in the build plan, the extension was omitted from the detected
skip: email@example.com provides unused vim).
Let’s take a look at how the
samples/vim extension installs
vim on the builder image…