Under the hood

How Buildpacks Work

From source code to a production-ready container image, without writing a Dockerfile. Scroll to follow a build from start to finish.

Scroll to explore

Step 01 · Source

It starts with your source code

Point a platform such as pack at your app. There’s no Dockerfile to write or maintain: buildpacks work out what your app needs and how to package it.

What is a platform?

Step 02 · Builder

A builder brings the tools

A builder is an image that bundles an ordered set of buildpacks, a build-time base image to run them in, the lifecycle that orchestrates every phase, and a reference to the runtime base image your app will ship on.

What is a builder?

Step 03 · Detect

Buildpacks decide if they apply

After analyzing any previously built image, the lifecycle asks each buildpack, in order, whether it recognizes your app. A package.json lets the Node.js buildpack pass, a requirements.txt lets Python pass, and optional buildpacks with nothing to do simply opt out.

Learn about detection

Step 04 · Restore

Cached layers come back

The lifecycle restores layers saved by earlier builds from the cache, so dependencies that haven’t changed don’t have to be downloaded or compiled again. Rebuilds stay fast.

Learn about restoring

Step 05 · Build

Each buildpack contributes layers

The lifecycle runs each participating buildpack inside the build-time base image, and each one contributes its own layers: a language runtime, installed dependencies, your compiled app. Every layer is isolated, cacheable and can be described in a software bill of materials.

Learn about the build phase

Step 06 · Export

Out comes an OCI image

The lifecycle stacks those layers on top of the runtime base image and exports a standard OCI image, ready to push to any registry, with no build tools left inside.

Learn about exporting

Step 07 · Rebase

Patch the OS in seconds

When a vulnerability is fixed in the runtime base image, pack rebase swaps the base layers underneath your app without rebuilding it. Your app layers stay exactly as they were.

What happens during rebase?

Step 08 · Run

Run it anywhere

The result is a reproducible, well-structured container image that runs wherever containers do: on Kubernetes, on a cloud platform, or on your own machine.

Try it in the tutorial

Try it yourself

Build an image from your app's source code with the pack CLI:

pack build my-app --builder cnbs/sample-builder:resolute

Start Tutorial Read the Docs

Dive deeper

Buildpacks

What a buildpack is and how it inspects and builds your app.

Read more

Builders

How buildpacks, base images and the lifecycle are packaged together.

Read more

Lifecycle

Every phase the lifecycle runs, from analyze through export.

Read more

Rebase

How app images get OS updates without a rebuild.

Read more