Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Build applications with Paketo Buildpacks and Red Hat UBI container images

June 18, 2024
Michael Dawson Ozzy Osborne Costas Papastathis
Related topics:
ContainersJavaNode.jsQuarkus
Related products:
Red Hat build of Node.jsRed Hat build of OpenJDKRed Hat Enterprise LinuxRHEL UBI

Share:

    https://developers.redhat.com/articles/2024/08/26/running-applications-paketo-buildpacks-and-red-hat-ubi-container-imagesWith the growth in the use of containers, the need to bundle your application into a container has never been stronger. Many Red Hat customers will be familiar with Source-to-Image (S2I) as an easy way to build container images from application source code. While S2I is a convenient way to build images on Red Hat OpenShift, Red Hat works to support our customers when using a variety of approaches, and we’ve recently seen an increasing interest in building applications using Cloud Native Computing Foundation (CNCF) Buildpacks.  

    This is the first in a 5-part series of articles on building your applications with CNCF Buildpacks and UBI. The series will include:

    • Building applications with Paketo Buildpacks and Red Hat UBI container images (this post)
    • Running applications with Paketo Buildpacks and Red Hat UBI container images in OpenShift
    • The journey to enable UBI with the Paketo Buildpacks
    • Building applications with UBI and Paketo Buildpacks in CI/CD
    • Building a container image for a Quarkus project using buildpacks

    CNCF Buildpacks

    There are a number of CNCF Buildpacks implementations and one of the leading ones is Paketo Buildpacks, which have a long pedigree, having been based on buildpacks used in Cloud Foundry. Traditionally the Paketo ecosystem was centered around Debian (Ubuntu) based images along with external tarballs to install runtimes. Use of the Linux distribution runtime packages was difficult because CNCF Buildpacks deliberately disallowed dependencies that required root to modify the build environment. The TLDR; is that buildpacks pulled in third party tarballs (unsupported) instead of being able to leverage runtimes from Linux distributions like Red Hat supported rpms.

    Universal Base Images (UBI)

    Red Hat Universal Base Images (UBI) are OCI-compliant container base operating system images with complementary runtime languages and packages that are freely redistributable. They make great images to build your applications on, bringing with them the advantages of the Red Hat Enterprise Linux (RHEL) ecosystem. You can read more about UBI in Introducing the Red Hat Universal Base Image.

    Enabling UBI in buildpacks

    A few years ago, due to the increasing interest in building applications using CNCF Buildpacks expressed by our customers, Red Hatters started to work with the CNCF community to extend the buildpack specification to enable the creation of UBI builder images that made use of the supported Red Hat Runtimes. 

    The key addition was support for image extensions. With that support, Red Hatters have worked with Paketo to create extensions to support Node.js and Java as well as the ubi-base-stack and builder-ubi-base that you need in order to use them with UBI container images. These are still working their way through the hardening process as the image extension feature is still experimental in the specification, however, now is a great time to try them out and give us feedback so that we can improve them based on real-world experience.

    What’s the same or different when using UBI?

    The builder-ubi-base and the bundled buildpacks support the same options as when building with other stacks. There are a few differences in the end result which we feel are well aligned with the Red Hat approach to supporting runtimes. These include:

    • The use of UBI images (of course).
    • The application will always be built with the most recent runtime, and staged onto the most recent version of the container for the major version of the runtime selected. For example, if your application requests Node.js 20, the latest version of the ubi8/nodejs-20 container will be used. This fits the model where you get vulnerability fixes through the latest container and, therefore, want to be running on the latest version of the container for a major version of a runtime.

    Building applications with UBI and the Paketo Buildpacks

    In order to be able to build and run an application using buildpacks from the command line, we need to install the tools for the build process and for running containers. This can be done with Docker or Podman. We will show you how to do it with Podman.

    For the build process as well as running the container, you need Podman version 5.1.0 or later. We installed it on Fedora 40 following these instructions. Make sure you start the socket and set DOCKER_HOST as directed in the instructions. Once installed, you should check that the version is 5.1.0 or later with:

    podman --version

    If the version is not yet 5.1.0 or later you can try updating with:

    dnf update podman 

    If that still does not get you 5.1.0 you can install the test version of 5.1.0 with the following command:

    sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-c612accb0f

    In addition, for the build process, we also need the Pack CLI. On Fedora you can install it with:

    dnf install pack

    In our case it was version 0.32.0. You can install newer versions by following the instructions from the official website. At the time this article was written, we also tried out the latest version, 0.34.1, and it worked fine as well.

    After installing the tools, we are ready to build our applications. We’ll walk you through the process of building and running some of the existing Paketo application samples for a Node.js application as well as a Java application.

    A Node.js application

    Start by cloning the Paketo samples repository:

    git clone https://github.com/paketo-buildpacks/samples

    Navigate to the root directory of the sample Node.js app:

    cd samples/nodejs/npm

    As mentioned earlier, the extension that the builder is using during the build process is currently in an experimental state. Therefore, we need to enable the experimental features of pack CLI:

    pack config experimental true

    Build the app with pack CLI by using the ubi-base builder:

    pack --docker-host=inherit build my-node-app --builder paketocommunity/builder-ubi-base

    If the build has finished successfully, the image should be visible and named my-node-app. 

    Run the image:

    podman run -d -p 8080:8080 my-node-app

    The container should be up and running on port 8080, so we can make an HTTP request with curl or any other HTTP client you prefer.

    curl http://localhost:8080

    A Java application

    Start by cloning the Paketo samples repository:

    git clone https://github.com/paketo-buildpacks/samples

    Navigate to the root directory of the sample Java app:

    cd samples/java/maven

    As mentioned earlier, the extension that the builder is using during the build process is currently in an experimental state. Therefore, we need to enable the experimental features of pack CLI:

    pack config experimental true

    Build the app with pack CLI by using the ubi-base builder:

    pack --docker-host=inherit  build my-java-app --builder paketocommunity/builder-ubi-base

    If the build has finished successfully, the image should be visible and named my-java-app. 

    Run the image:

    podman run -d -p 8080:8080 my-java-app 

    The container should be up and running on port 8080, so we can make an HTTP request with curl or any other HTTP client you prefer on /actuator/health:

    curl http://localhost:8080/actuator/health

    Summing up

    From the last section, you can see that the ubi-base-builder builds your Node.js or Java application just like with any other Paketo builder image. The same configuration options are available and the application should run the same, except that it will be using the UBI container and the Red Hat version of either the Node.js or Java runtime.

    We hope you found this article interesting and that we have motivated you to try out the new Paketo UBI Builder Image. In the follow-up posts we will provide more detail on running applications with Paketo Buildpacks in OpenShift, the journey to enable UBI within the Paketo ecosystem, using buildpacks in CI/CD, and using CNCF Buildpacks with Quarkus.

    Last updated: January 21, 2025

    Related Posts

    • Build lean Node.js container images with UBI and Podman

    • Working with Red Hat Enterprise Linux Universal Base Images (UBI)

    • Build lightweight and secure container images using RHEL UBI

    • Deploying serverless Node.js applications on Red Hat OpenShift, Part 1

    • What's new in the Red Hat UBI OpenJDK containers

    • Building freely distributed containers with Podman and Red Hat UBI

    Recent Posts

    • How to use RHEL 10 as a WSL Podman machine

    • MINC: Fast, local Kubernetes with Podman Desktop & MicroShift

    • How to stay informed with Red Hat status notifications

    • Getting started with RHEL on WSL

    • llm-d: Kubernetes-native distributed inferencing

    What’s up next?

    Read this e-book to learn about the benefits of using Red Hat Universal Base Images (UBI).

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue