back to all blogsSee all blog posts

Deploy Java applications to Azure and Google Cloud using Paketo Buildpacks

image of author
Kevin Ortega on Feb 17, 2023
Post available in languages:

Azure and Google Cloud have built-in support for cloud native buildpacks. You can use Azure or Google Cloud to easily deploy Java applications by using the Paketo Buildpack for Liberty with your source code or container images.

This post provides instructions on how to use the Paketo Buildpack for Liberty with Azure and Google Cloud. To learn more about using Azure and Google Cloud, see their respective documentation.

What do you need?

To build and deploy container images or create a custom builder, you’ll also need:

  • The cloud native buildpack pack CLI

  • Docker or Podman. This post focuses on Docker. For information about using Podman with Paketo, refer to the documentation for Building on Podman.

  • An externally accessible container registry that can host your images.

The Paketo Buildpack for Liberty is included in the composite Paketo Buildpack for Java that also includes tomcat and tomee application servers. Tomcat is the default application server and to use Open Liberty requires a little extra configuration. The Paketo Buildpack for Java includes Bellsoft Liberica as the default JVM provider. To use other JVM providers requires extra configuration.

You can set the application server that the Paketo Buildpack for Java uses by specifying the BP_JAVA_APP_SERVER environment variable and select an alternate JVM provider using a project descriptor.

Let’s get started

Create the project descriptior file, project.toml, in the application’s root source directory. At a minimum, project.toml must specify the BP_JAVA_APP_SERVER=liberty environment variable but can contain other environment variables that are consumed by buildpacks.

To use the alternate and preferred Eclipse OpenJ9 JVM, change the order that the buildpacks run in the project descriptor. To minimize the size of the application container image, the buildpack installs the Liberty kernel profile by default. You can override the profile using the BP_LIBERTY_PROFILE environment variable or use the BP_LIBERTY_FEATURES environment variable to install the Liberty features your application requires.

For example, your project descriptor might contain the following content to use the Liberty runtime and install Eclipse OpenJ9, the Liberty kernel profile, and a set of Liberty features:

    name = "BP_JAVA_APP_SERVER"
    value = "liberty"

    value = "jsonb-2.0 mpconfig-3.0 mpmetrics-4.0 restfulws-3.0 jsonp-2.0 cdi-3.0"

  uri = "docker://"

  uri = "docker://"

Build and push a container image with Azure

Use the az acr pack build command to build and push a container image using the built-in cloud native buildpack support. For example, the following command builds and pushes the container image using the mycr Azure container registry and the full Paketo Buildpacks builder. The resulting image name is myapp and the application source resides in ~/myappsourcedir. The application source can also be specified as the URL of a Git repo. This example assumes the mycr Azure container registry was previously created.

az acr pack build
    --registry mycr
    --pull --builder paketobuildpacks/builder:full
    --image myapp

Build and push a container image with Google Cloud

Use the gcloud builds command to build and push a container image using the built-in cloud native buildpack support. Follow the Before you begin instructions to setup your environment.

The command uses the following basic syntax:

gcloud builds submit --pack

In the following example, us-east1 is the LOCATION, paketobuildpacks is the PROJECT_ID, paketobuildpacktest is the REPO_NAME and javatest is the IMAGE_NAME. The command is executed from the application’s root directory.

gcloud builds submit --pack,builder=paketobuildpacks/builder:full

Liberty environment variables you can set in the project.toml file


Specifies the Install type of Liberty. Open Liberty (value of ol) is the default. Use wlp for WebSphere Liberty.


Specifies which Liberty profile to install. Valid profiles for Liberty are documented in the buildpacks documentation. The default profile is kernel.


Specifies a space-separated list of Liberty features to be installed with the Liberty runtime. Supports any valid Liberty feature.

Take full advantage of the Paketo Buildpack for Liberty with the pack build CLI

Some features of the Paketo Buildpack for Liberty are not easily available to Azure or Google Cloud. Features like installing iFixes, custom features, and installing from a packaged server or server directory aren’t available when you use the built-in support to create the container image.

For these features, you can use the pack build CLI to create the container image, tag and push the image to an external container registry. Then, use Azure or Google Cloud to deploy and manage your container by pulling your container image from the container registry. See Introducing the Paketo Liberty Buildpack for details on using the pack build CLI with Liberty.