Paketo buildpacks transform your application source code into container images and easily keep them updated.
What is a buildpack?
A buildpack is a set of executables that inspects your application source code and creates a plan to build your application.
Paketo buildpacks implement the Cloud Native Computing Foundation buildpack specification to provide toolkits and workflows for building reproducible container images from source code.
The Paketo Liberty buildpack provides the Open Liberty runtime to a workflow that produces an Open Container Initiative (OCI) image that can run just about anywhere.
Why use the Paketo Liberty buildpack?
You can build your application without creating a Dockerfile!
Advanced Caching: Paketo buildpacks use built-in caching to improve performance so you can quickly rebuild your application by updating only the layers that have changed.
Bill-of-Materials: a built-in software bill of materials (SBOM) support provides insights into the contents of the application image.
Minimal Application Image: images contain only what is necessary.
Reproducibility: reproduce the same application image digest by re-running the build.
Auto-detection: images are built directly from application source.
Rebasing: instantly update base images without rebuilding your source code by patching the OS layer of your image.
Let’s get started!
The following examples use the Open Liberty starter application as the application source. Download the Open Liberty starter application:
git clone https://github.com/openliberty/guide-getting-started.git cd guide-getting-started/start
Set a default builder:
pack config default-builder gcr.io/paketo-buildpacks/builder:base
Build the application with only the Liberty features required to run the application and IBM Semeru OpenJ9:
pack build --env BP_JAVA_APP_SERVER=liberty --env BP_LIBERTY_PROFILE=kernel \ --env BP_LIBERTY_FEATURES='jaxrs-2.1 jsonp-1.1 cdi-2.0 mpMetrics-3.0 mpConfig-2.0' \ --buildpack paketo-buildpacks/eclipse-openj9 --buildpack paketo-buildpacks/java myapp
Your application is now transformed into an OCI image!
With your OCI image, you can run your application locally with the
docker run command.
We need to provide a
server.xml file to the Liberty buildpack by using a binding.
Create a directory named
bindings, for example.
Create a file named server.xml in the
bindingsdirectory with the following content:
<server description="Intro to the Paketo Liberty buildpack"> <featureManager> <feature>mpconfig-2.0</feature> <feature>mpmetrics-3.0</feature> <feature>cdi-2.0</feature> <feature>jsonp-1.1</feature> <feature>jaxrs-2.1</feature> </featureManager> <mpMetrics authentication="false"/> <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint" host="*" /> </server>
In the same directory, create a file named
typewith the following content:
Your directory structure should look like this:
bindings |__server.xml |__type
Now run your application with the bindings:
docker run --rm -p 9080:9080 --env SERVICE_BINDING_ROOT=/bindings \ --volume <absolute path to bindings>:/bindings/liberty myapp
Build your app from an on-prem Open Liberty installation
You can build from an on-prem Open Liberty installation by using a packaged Liberty server. Run the following command to package your server.
bin/server package defaultServer --include=usr
You can then supply the packaged server to the build by using the
pack build --path <packaged-server-zip-path> \ --buildpack paketo-buildpacks/eclipse-openj9 \ --buildpack paketo-buildpacks/java myapp
Alternatively, you can build from a Liberty server installation by changing your working directory to the installation root that contains the
wlp directory and running the following command:
pack build \ --buildpack paketo-buildpacks/eclipse-openj9 \ --buildpack paketo-buildpacks/java myapp