back to all blogsSee all blog posts

Introducing the Paketo Liberty Buildpack

image of author image of author
Kevin Ortega and Hank Ibell on Apr 1, 2022
Post available in languages:

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.

What do you need?

Let’s get started!

The following examples use the Open Liberty starter application as the application source.

Currently, Paketo buildpacks cannot be used locally on machines running with an M1 or M2 processor. For more information, see this blog post.

Download the Open Liberty starter application:

git clone https://github.com/openliberty/guide-getting-started.git
cd guide-getting-started/finish

Set a default builder:

pack config default-builder paketobuildpacks/builder-jammy-base

Create project.toml file in the finish directory with the following content:

[[build.env]]
    name = "BP_JAVA_APP_SERVER"
    value = "liberty"

[[build.env]]
    name = "BP_MAVEN_BUILT_ARTIFACT"
    value ="target/*.[ejw]ar src/main/liberty/config/*"

[[build.buildpacks]]
  uri = "docker://gcr.io/paketo-buildpacks/eclipse-openj9"

[[build.buildpacks]]
  uri = "docker://gcr.io/paketo-buildpacks/java"

Build the application on Liberty with IBM Semeru OpenJ9 and required Liberty features:

 pack build myapp

Your application is now transformed into an OCI image!

Now what?

With your OCI image, you can run your application locally with the docker run command.

Now run your application:

docker run --rm -p 9080:9080 myapp

or deploy your application to any Kubernetes-based platform, such as Red Hat OpenShift, by using an Open Liberty operator

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 --path argument:

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

Learn more: