Configuration examples will use the Paketo sample applications.
Examples assume that the root of this repository is the working directory:
git clone https://github.com/paketo-buildpacks/samples cd samplesCopied!
Examples assume that the Paketo Base builder is the default builder:
pack set-default-builder paketobuildpacks/builder:baseCopied!
Paketo buildpacks can be configured via the following mechanisms:
Users may configure the build by setting variables in the buildpack environment. The names of variables accepted by the Paketo buildpacks at build-time are either prefixed with
BP_ or have well-known conventional meanings outside of Paketo (e.g.
The following example uses an environment variable to configure the JVM version installed by the Java Buildpack.
pack build samples/java \ --path java/jar \ --env BP_JVM_VERSION=8Copied!
During the build process, a buildpack may invoke other programs that accept configuration via the environment. Users may configure these tools as they would normally. For example, the command below configures the JVM memory settings for the JVM running Maven using
pack build samples/java \ --path java/maven \ --env "MAVEN_OPTS=-Xms256m -Xmx512m"Copied!
Users may configure runtime features of the app image by setting environment variables in the app container. The names of variables accepted by buildpack-provided runtime components (e.g. profile scripts and processes types) are prefixed with
BPL_ or have well-known conventional meanings outside of Paketo (e.g
The following example uses
JAVA_TOOL_OPTIONS to set the server port of the sample application:
docker run --rm --publish 8082:8082 --env "JAVA_TOOL_OPTIONS=-Dserver.port=8082" samples/java curl -s http://localhost:8082/actuator/healthCopied!
Programs invoked at runtime, including the application itself, will accept environment as they would normally.
Many Paketo buildpacks accept configuration from a
buildpack.yml file if one is present at the root of the application directory.
For example, to configure the NodeJS version installed by the NodeJS Buildpack, create a file named
buildpack.yml in the
nodejs/yarn directory in the samples repo.
nodejs: version: 12.12.0Copied!
Next, execute the build as normal and observe the that the specified version of NodeJs is installed.
pack build samples/nodejs --path nodejs/yarnCopied!
Some Paketo Buildpacks and components installed by the Paketo Buildpacks accept credentials and other secrets using bindings at build and runtime. Commonly, bindings provide the location and credentials needed to connect to external services.
Some categories of external services one might want to bind at build-time include:
For example, the Maven buildpack accepts the location and credentials need to connect to a private Maven repository in a binding.
Some categories of external services one might want to bind at runtime include:
For example, the Spring Boot Buildpack will install Spring Cloud Bindings which is capable of auto-configuring Spring Boot application configuration properties to connect the application to a variety of external services, when a binding is provided at runtime.
A Binding contains:
ApplicationInsightscontains the credentials needed to connect to Azure Application Insights.
ApplicationInsightsbinding may contain a key-value pair with key
Bindings must be presented to buildpacks as directories (typically volume mounted) on the container filesystem. The name of the directory provides the name of the binding. The contents of a binding can be provided using one of two specifications.
Paketo Buildpacks will look for bindings in the
/platform/bindings directory at build-time and in
$CNB_BINDINGS directory at runtime.
For example, the Java Buildpack accepts a binding with
type equal to
maven containing a key named
settings.xml containing Maven settings. In the build container, the Maven Buildpack will use
settings.xml if it finds either
/platform └── bindings └── <name> ├── settings.xml └── typeCopied!
on the filesystem, where either the
/platform └── bindings └──<name> └── metadata | └── kind └── secret └── settings.xmlCopied!
kindfile contains the string
The workflow for creating a binding and providing it to a build will depend on the chosen platform. For example,
pack users should use the
--volume flag to mount a binding directory into the build or app containers. Users of the
kpack platform should store key value pairs in a Kubernetes Secret and provide that secret and associated metadata to an Image as described in the kpack documentation.
Example: Providing a Binding to
Given a directory containing a build-time binding,
pack users can provide this binding to a Paketo buildpack using the
pack build --volume <absolute-path-to-binding>:/platform/bindings/<binding-name> <image-name>Copied!
Example: Providing a Binding to
Given a directory containing a runtime binding,
docker users can provide the binding to the app image using the
docker run --env SERVICE_BINDING_ROOT=/bindings --volume <absolute-path-to-binding>:/bindings/<binding-name> <image-name>Copied!
Paketo users may override buildpack-provided types or augment the app-image with additional process types using a
Procfile support is provided by the Paketo Procfile Buildpack. The Procfile Buildpack will search for a file named
Procfile at the root of the application.
Procfiles should adhere to the following schema:
If a given language family buildpack does not contain the Procfile Buildpack it can be explicitly appended at runtime.
Example: A Hello World Procfile
The following adds a process with
type equal to
hello and makes it the default process.
echo "hello: echo hello world" > nodejs/yarn/Procfile pack build samples/nodejs \ --path nodejs/yarn \ --buildpack gcr.io/paketo-buildpacks/nodejs \ --buildpack gcr.io/paketo-buildpacks/procfile \ --default-process hello docker run samples/nodejs # should print "hello world"Copied!
Paketo Buildpacks can be configured to route traffic through a proxy using the
no_proxy environment variables.
pack will set these environment variables in the build container if they are set in the host environment.
Paketo Buildpacks may download dependencies from the internet. For example, the Java Buildpack with download the BellSoft Liberica JRE will from the Liberica github releases by default.
If a dependency URI is inaccessible from the build environment, a binding can be used to map a new URI to a given dependency. This allows organizations to upload a copies of vetted dependencies to an accessible location and provide developers and CI/CD pipelines with configuration pointing the buildpack at the accessible dependencies.
The URI mappings can be configured with one or more bindings of
dependency-mapping. Each key value pair in the binding should map the
sha256 of a dependency to a URI. Information about the dependencies a buildpack may download (including the
sha256 and the current default
uri) can be found in the
buildpack.toml of each component buildpack.
Example Mapping the JRE to an internal URI
For example, to make the Bellsoft Liberica JRE dependency accessible available to builds in an environment where Github is inaccessible, an operator should:
urifor the desired dependency in buildpack.toml of the Bellsoft Liberica buildpack. Example values:
uriand upload it to a location on the internal network that is accessible during the build.
sha256of the dependency and the value is equal to the new URI.
Additional CA certificates may be added to the system truststore using the Paketo CA Certificates Buildpack.
CA certificates can be provided at both build and runtime with a binding of
ca-certficates. Each key value pair in the binding should map a certficate name to a single PEM encoded CA Certficates
<binding-name> ├── <cert file name> └── type
If a given language family buildpack does not contain the Paketo CA Certificates Buildpack it can be explicitly prepended at runtime.
Example: Adding a CA Certificate at Runtime
The samples repository contains a simple Golang application that will make a
HEAD request to a provided URL.
Given a file
<your-ca.pem> containing a single PEM encoded CA certificate needed to verify a TLS connection to an https URL
<url>, add the CA certificate to the binding.
cp <your-ca.pem> ca-certificates/binding/
The provided sample contains a simple Golang application that will make a
HEAD request to a provided URL. Build the application using the CA Certificates buildpack
pack build samples/ca-certificates \ --path ca-certificates \ --buildpack paketo-buildpacks/ca-certificates \ --buildpack paketo-buildpacks/go
Run the sample application, providing the binding, and passing the URL as a positional argument (should print
docker run --rm \ --env SERVICE_BINDING_ROOT=/bindings \ --volume "$(pwd)/ca-certficates/binding:/bindings/ca-certificates" \ samples/ca-certificates <url>
Paketo users may add labels to the application image using the Image Labels Buildpack.
Environment variables prefixed with
BP_OCI_ can be used to set OCI-specific. For example, if
BP_OCI_AUTHORS is set at build-time, the Image Labels Buildpack will add a label to the image with key
org.opencontainers.image.authors and value equal to the value of
Users may contribute arbitrary labels by providing a collection of space-delimited key-value pairs with the
BP_IMAGE_LABELS environment variable. Values containing spaces can be quoted.
If a given language family buildpack does not contain the Image Labels Buildpack it can be explicitly appended at runtime.
Example: Adding Custom Labels
pack build samples/nodejs \ --path nodejs/yarn \ --buildpack gcr.io/paketo-buildpacks/nodejs \ --buildpack gcr.io/paketo-buildpacks/image-labels \ --env "BP_OCI_DESCRIPTION=Demo Application" \ --env 'BP_IMAGE_LABELS=io.packeto.example="Adding Custom Labels"' docker inspect samples/nodejs | jq '..Config.Labels["org.opencontainers.image.description"]' # should print "Demo Application" docker inspect samples/nodejs | jq '..Config.Labels["io.packeto.example"]' # should print "Adding Custom Labels"Copied!
Last modified: January 12, 2021