Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding
  1. Home
  2. Developers
  3. Using Buildpacks to provision OCI-compliant container images

Using Buildpacks to provision OCI-compliant container images

  • By Gcore
  • March 23, 2023
  • 2 min read
Using Buildpacks to provision OCI-compliant container images

It never fails that the CNCF (Cloud Native Computing Foundation) seems to always be cooking up something interesting in their ecosystem. It’s exciting to play with the CNCF Sandbox projects to see what new cutting-edge tools we can add to our collection. It is our goal today to introduce you to a project at the Sandbox stage known as “Buildpacks”.

What are Buildpacks?

Buildpacks are an OCI-compliant tool for building applications that serve as a higher-level abstraction as opposed to writing Dockerfiles. The project was spawned by Pivotal and Heroku in 2011 and joined the Cloud Native Sandbox in October 2018. Since then, Buildpacks has been adopted by Cloud Foundry and other PaaS such as Gitlab, Knative, Deis, Dokku, and Drie.

The project seeks to unify the buildpack ecosystems with a platform-to-buildpack contract that is well-defined and that incorporates years of learning from maintaining production-grade buildpacks at both Pivotal and Heroku.

Installing pack

In this demo, we’re going to learn how to use pack and buildpacks to create a runnable app image from source code.

Prerequisites

  • Docker

You can install the most recent version of pack (version 0.6.0) as an executable binary on the following operating systems:

macOS

To install pack on macOS, the easiest way is to use Homebrew:

brew tap buildpack/tapbrew install pack

Linux

wget https://github.com/buildpacks/pack/releases/download/v0.6.0/pack-v0.6.0-linux.tgztar xvf pack-v0.6.0-linux.tgzrm pack-v0.6.0-linux.tgz./pack --help

From there, you can copy the executable to a directory like /usr/local/bin or add the current directory to your PATH.

Windows

You can install the Windows executable pack by downloading the Windows ZIP file.

Building an app

Building an app using Cloud Native Buildpacks is very straightforward.

Select a builder

To build an app you must first decide what builder you are going to use. A builder includes the buildpacks that will be used as well as the environment for building and running your app.

When using the pack, you can run pack suggest-builders for a list of suggested builders.

pack suggest-builders

For this tutorial, we’re actually going to use a sample builder, cnbs/sample-builder:bionic, which is not listed as a suggested builder for good reason. It’s a sample.

Build your app

Now that you’ve decided on what builder to use, we can build our app. For this example, we will use our samples repo for simplicity.

# clone the repogit clone https://github.com/buildpacks/samples# build the apppack build sample-app --path samples/apps/java-maven/ --builder cnbs/sample-builder:bionic

Tip: If you didn’t want to keep specifying a builder every time you build, you could set it as your default builder by running pack set-default-builder <BUILDER>.

Run it

docker run --rm -p 8080:8080 sample-app

Congratulations!

The app should now be running and accessible via localhost:8080.

Explore Gcore Container as a Service

Related articles

What's the difference between multi-cloud and hybrid cloud?

Multi-cloud and hybrid cloud represent two distinct approaches to distributed computing architecture that build upon the foundation of cloud computing to help organizations improve their IT infrastructure.Multi-cloud environments involve us

What is multi-cloud? Strategy, benefits, and best practices

Multi-cloud is a cloud usage model where an organization utilizes public cloud services from two or more cloud service providers, often combining public, private, and hybrid clouds, as well as different service models, such as Infrastructur

What is cloud migration? Benefits, strategy, and best practices

Cloud migration is the process of transferring digital assets, such as data, applications, and IT resources, from on-premises data centers to cloud platforms, including public, private, hybrid, or multi-cloud environments. Organizations can

What is a private cloud? Benefits, use cases, and implementation

A private cloud is a cloud computing environment dedicated exclusively to a single organization, providing a single-tenant infrastructure that improves security, control, and customization compared to public clouds.Private cloud environment

What is a cloud GPU? Definition, types, and benefits

A cloud GPU is a remotely rented graphics processing unit hosted in a cloud provider's data center, accessible over the internet via APIs or virtual machines. These virtualized resources allow users to access powerful computing capabilities

What is cloud networking: benefits, components, and implementation strategies

Cloud networking is the use and management of network resources, including hardware and software, hosted on public or private cloud infrastructures rather than on-premises equipment. Over 90% of enterprises are expected to adopt cloud netwo

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.