What Are Cloud Native Buildpacks? Docker Images Without a Dockerfile, pack, kpack and Rebase on kind

A Docker image with no Dockerfile, a base image swapped without a rebuild, and the three crashes I hit on Apple Silicon. pack, kpack and rebase on kind.

By Mirac Can Yılmaz 19 min read
What Are Cloud Native Buildpacks? Docker Images Without a Dockerfile, pack, kpack and Rebase on kind - platform-engineering yazısının kapak görseli

I built a Docker image on an Apple Silicon Mac with no Dockerfile at all, and the build died inside the SBOM step with panic: reflect: Elem of invalid type cyclonedx.CryptoProperties [recovered, repanicked]. I had expected the hard part to be learning a new tool. The hard part was that the all-in-one builder everybody points you to is built for a different CPU than my laptop, and the tool never said so.

That crash is where this post starts, but it is not what it is about. It is about what Cloud Native Buildpacks give a platform team that a pile of Dockerfiles does not: one way to turn source into an image, an inventory of what went into it, and the ability to change the base image under an existing image without compiling anything again. By the end you will have seen two apps built without a Dockerfile, an SBOM read out of an image, a base image patched in place, and the same build moved into a kind cluster where a controller does it. You will also have the list of things that broke, with the exact error lines, and a table of when I would still write a Dockerfile.

What are Cloud Native Buildpacks?

Cloud Native Buildpacks (CNB) is a CNCF project that turns application source into an OCI image without a Dockerfile. It standardises the idea Heroku has run behind git push for years. You give it a directory, it works out what the directory is, and it produces an image.

The pieces, in the order you meet them:

  • Buildpack: a small module that knows one language or one job. One looks for go.mod and installs a Go toolchain; another looks for requirements.txt and runs pip.
  • Builder: a build image plus an ordered list of buildpacks plus a pointer to a run image. This is the thing pack and kpack actually run.
  • Stack: the pair of base images underneath: a build image the buildpacks run in, and a run image the final application runs on.
  • Lifecycle: the program that drives the phases: analyze, detect, restore, build, export.
  • pack: the command-line client. kpack: a Kubernetes controller that does the same work from a custom resource.

Paketo is the most widely used set of buildpacks. Heroku and Google ship their own, and the mechanism is the same.

Two phases explain most of it. In detect, every buildpack looks at the source and answers "is this mine?". The ones that say yes form the group for this build. In build, those buildpacks run in order: fetch the Go toolchain, compile, write the launch command. Each one leaves its output in its own layer, so the next build can reuse what did not change.

The result is an ordinary image with one difference. Its metadata records which layers came from the run image and which came from your application. That single fact is what makes rebase possible, and rebase is the reason to care.

The problem, and why it matters

Picture a platform with a hundred services. There are a hundred Dockerfiles. Some were copied from a template years ago, some still start from a base nobody maintains, and some carry one team's personal taste about users and caches. Then a critical vulnerability is published for a package in the base image. The work is obvious and awful: change a hundred Dockerfiles, run a hundred pipelines, rebuild a hundred images, redeploy a hundred services, and hope none of the rebuilds picks up something unrelated that was fine yesterday.

The pain is not writing a Dockerfile. It is that the base image and the application are welded together at build time, so changing the first means redoing the second. Everyone who has patched a base image across many services knows the shape of that day.

Buildpacks attack it from the other side. They keep the base image and the application as separate layers and record the boundary. Patching the base becomes an operation on a registry: take the existing application layers, put them on a new base, publish. Nothing is compiled. The claim I wanted to test is narrow and practical: not "stop writing Dockerfiles", but "stop compiling on patch day".

What you get, and what it costs

What you get What it means day to day What it costs
Rebase A base image fix reaches existing images without a rebuild Only for the base. A vulnerable dependency in your own code still needs a real build
One build path Go and Python built with the same command in the same pipeline step You learn project.toml, BP_* settings and buildpack order instead of Dockerfile instructions
SBOM inside the image The inventory travels with the image and can be read without running it You still have to feed it to something that scans it
Non-root by default The image runs as a non-root user without anyone writing USER You find out about it when something needs root and fails
No Dockerfile to maintain Caches, multi-stage and users are inside the buildpack When a build fails, the error is inside a buildpack, not on line 12 of a file you own

Every row has a right-hand column on purpose. Teams that kept buildpacks and teams that went back to Dockerfiles used the same tool; the difference was usually which of these costs they had a plan for.

How it works: detect, build, export, rebase

A pack build is five steps you can read in the log. Analyze looks for a previous image to reuse layers from. Detect runs every buildpack's check against the source. Restore brings back cached layers. Build runs the chosen buildpacks. Export writes the image: the run image's layers at the bottom, the buildpacks' layers on top, plus the SBOM and some metadata labels.

Rebase is not a build. It rewrites the image's manifest so the application layers sit on a different set of base layers, and uploads the result. The compiler, the package manager and the detect step never run. It is safe only because the run image keeps the same ABI contract as the one it replaces, which is why a rebase is tied to the stack: same stack id, new content.

kpack moves the whole thing into a cluster. A ClusterStack names the build and run images. ClusterBuildpack objects name the buildpacks. A ClusterBuilder combines them and is pushed to a registry as an image. A developer-facing Image object points at a source and a builder. The controller then watches three things: the source, the builder, and the stack. A change to the first two triggers a build. A change to the stack triggers a Build whose reason is STACK, and, as the lab shows, that Build only rebases.

Diagram: on the left, pack build for the lab's Go service. The source directory with go.mod, main.go and project.toml goes into detect, where ca-certificates, go-dist, go-mod-vendor and go-build say yes; a directory nobody claims stops with No buildpack groups passed detection. Build installs the Go toolchain, runs go build and writes the launch command; a Go version it cannot supply stops with failed to satisfy go >= 1.99. Export stacks the app layers, the SBOM in CycloneDX, SPDX and Syft, and lifecycle metadata labels on the run image run-jammy-base, and records the boundary, which pack inspect shows as Rebasable: true. On the right, rebase: the same app layers move from run-jammy-base:0.1.290 to a newer run-jammy-base, app layers identical, base layers replaced, the image still answers. Rebase onto run-jammy-full is refused with not found in existing run image metadata. Below, kpack: the ClusterStack run image goes from 0.1.290 to 0.1.303; build-1 with reason CONFIG ran prepare, analyze, detect, restore, build and export, build-2 with reason STACK ran rebase only. Rebase does not fix a vulnerable library in the application layers.

The lab

Everything ran on one Apple Silicon Mac: pack on the host, a kind cluster, and ttl.sh as an anonymous registry. Every phase has assertions, and a clean run of all of them passes.

1. Two apps, no Dockerfile

One small Go service and one small Flask service. For each, a project.toml replaces what a Dockerfile would say about the builder:

[io.buildpacks]
builder = "paketobuildpacks/builder-jammy-buildpackless-base"

[[io.buildpacks.group]]
uri = "docker://docker.io/paketobuildpacks/go"

pack build printed the five phases. Detect picked four buildpacks for the Go app: CA certificates, Go Distribution, Go Mod Vendor and Go Build. The Python app needed a Procfile to say how to start. Both images answered on their ports.

Two details I did not expect. My go.mod says Go 1.25 and the image reports go1.27.4: the buildpack treats the version in go.mod as a floor and picks the newest one it supports, so the line is not a pin. And the image runs as a non-root user, which is also why the Deployment in step 4 can say runAsNonRoot and pass.

pack inspect reports the stack, the run image the image was built on, the buildpacks that took part with their versions, and Rebasable: true.

Terminal: pack build reports Successfully built image hello-go:v1 and hello-py:v1. pack inspect hello-go:v1 shows Stack io.buildpacks.stacks.jammy, run image docker.io/paketobuildpacks/run-jammy-base:latest, Rebasable: true, the buildpacks ca-certificates 3.14.7, go-dist 2.11.4, go-mod-vendor 1.1.50 and go-build 2.4.50, and the default process hello-go. The Go image answers hello from buildpacks: go1.27.4 on linux/arm64, runs as user 1002:1000, the Python image answers python 3.11.18 on aarch64, and the check passes: both images built without a Dockerfile and answer.

2. The SBOM that was already in the image

pack sbom download pulled the inventory out of the image without running it: CycloneDX, SPDX and Syft files for the launcher and for the Go build layer. The Go build's CycloneDX file lists the Go modules compiled into the binary, including the lifecycle's own. This is the part I would show a security team, because the answer to "what is in this image" is a file, not a guess, and a scanner can read it directly.

Terminal: pack sbom download writes sbom.cdx.json, sbom.spdx.json and sbom.syft.json for the lifecycle launcher and for the go-build targets layer, a syft file for ca-certificates and a legacy file. The components named in the CycloneDX files include /hello-go, /launcher, github.com/buildpacks/lifecycle, github.com/BurntSushi/toml, github.com/pkg/errors and golang.org/x/sys. PASS SBOM present in the image.

3. Rebase on the same image name

To have something to patch I built the image on a month-old run image, retagged locally as latest, so the base was old on purpose. That stands in for the day before a base image gets a fix; it is a simulation, not a real CVE.

pack rebase against the current latest printed Successfully rebased image. Comparing layer lists before and after: the base layers were different, the application layers at the top were identical, and the image still answered. The Go compiler never ran.

One refusal worth knowing about. Asking for a rebase onto a differently named run image (the larger run-jammy-full) failed with new base image ... not found in existing run image metadata. Rebase is meant for a new version of the same run image, not a swap to another one.

Terminal: the image is built on run-jammy-base:0.1.290 retagged as latest, 11 layers. Rebasing onto paketobuildpacks/run-jammy-full fails with ERROR: rebase app image: new base image 'paketobuildpacks/run-jammy-full' not found in existing run image metadata. Rebasing onto the same name with newer content prints Successfully rebased image 'hello-go:v1'. Layers before 11, after 11, the 7 application layers at the top identical, the first base layer changed: True. The check passes and the image still answers hello from buildpacks: go1.27.4 on linux/arm64.

4. The local image in kind

kind load copied the image onto the node and a Deployment with runAsNonRoot: true started it. That works only because the builder already made the user non-root. The Deployment needs imagePullPolicy: IfNotPresent, since the image exists on the node and nowhere else.

5. kpack: the cluster does the build

kpack went in with its release manifest, then a ClusterStack, a ClusterBuildpack for Go, a ClusterBuilder and an Image. The source was a tarball served by a small pod inside the cluster, so the lab needs no public git repository. kpack built the image in a build pod, pushed it to ttl.sh and wrote the digest into status.latestImage.

The Python buildpack stayed out of the kpack builder. With both buildpacks in the builder, creating it had not finished when I stopped waiting. With Go alone it finished. My reading, not something I proved: creating a ClusterBuilder copies every buildpack layer to the registry, so the registry's distance from the cluster decides how long it takes. A registry next to the cluster would not have this problem; an anonymous one across my home uplink did.

6. One edit to the stack, and a Build that only rebases

I started the ClusterStack on the month-old run image and then edited it to the current tag. kpack created a second Build for the Image with reason STACK. The log for that build opens by printing the old run image digest next to the new one. The pod behind it has a rebase step and nothing else: none of prepare, detect, restore or build ran. It is the same operation as the local rebase, driven by a controller across every Image that uses the stack.

It did not start on its own in either run; the clean run needed the same touch. See "Where it broke" 8.

Terminal: kpack in the kind cluster. ClusterStack jammy and ClusterBuildpack paketo-go are created and ready, the Image hello-go is ready with a latest image on ttl.sh, Build hello-go-build-1 succeeded and the check passes: kpack built hello-go from source and pushed it. Then the ClusterStack run image is patched from run-jammy-base:0.1.290. No Build appears on its own, the script touches the ClusterBuilder, and hello-go-build-2 appears. The build list shows hello-go-build-1 True CONFIG and hello-go-build-2 True STACK. Steps in the build-1 pod: prepare analyze detect restore build export. Steps in the build-2 pod: rebase. The rebase log shows Build reason(s): STACK with the old and new run image digests. PASS stack change produced a STACK build that only rebased.

7. Four failures on purpose

A directory with nothing a buildpack recognises failed in detect. A go.mod asking for a Go version that does not exist failed in the build phase. A build and a run image of different CPU architectures produced an image that exits at start. A pod pointing at an image that was never loaded into kind sat in ErrImagePull. The exact lines are below.

Terminal: four failures on purpose. 1, a directory no buildpack recognises: ERROR: No buildpack groups passed detection, Please check that you are running against the correct path, failed to detect: no buildpacks participating. 2, go.mod says go 1.99: failed to satisfy go dependency version constraint >= 1.99: no compatible versions on io.buildpacks.stacks.jammy stack. Supported versions are: 1.26.10, 1.26.11, 1.27.3, 1.27.4. 3, build and run image of different architectures: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8), container exited with code 82, ERROR: failed to launch: direct exec: no such file or directory. 4, an image never loaded into kind: pod state ErrImagePull, Failed to pull image hello-go:never-loaded. Each block ends with PASS.

Where it broke

1. panic: reflect: Elem of invalid type cyclonedx.CryptoProperties [recovered, repanicked]

The first build, using the all-in-one builder-jammy-base. The panic came from the Go Distribution buildpack while it generated an SBOM. That builder image is published for amd64 only, and Colima here runs without Rosetta, so it ran under emulation. I did not investigate the cause. Switching to the buildpackless builder and the multi-architecture Go buildpack made it disappear.

2. fatal error: concurrent map read and map write

An older builder tag, same emulation, a different crash, this time in the lifecycle's detector. Two different crashes in two different tools, both gone when everything ran natively, is why I suspect the emulation. I did not prove it.

3. WARNING: The requested image's platform (linux/amd64) does not match the detected host platform, then ERROR: failed to launch: direct exec: no such file or directory

The failed attempts had left an amd64 run image in the local Docker. A later build with --pull-policy if-not-present reused it, so an arm64 binary sat on an amd64 base. The build succeeded and the container exited at start. Passing --platform explicitly fixes it, and so does removing the stale image.

4. ERROR: rebase app image: new base image 'paketobuildpacks/run-jammy-full' not found in existing run image metadata

I tried to demonstrate rebase by swapping to a bigger variant of the same stack. The tool wants the new base to be a new version of a run image it already knows about. The honest demonstration is the same name with newer content.

5. ERROR: No buildpack groups passed detection.

On a directory that held only a README. The next two lines say Please check that you are running against the correct path. and failed to detect: no buildpacks participating. The usual cause in real life is the same: pointing --path at the wrong directory.

6. failed to satisfy "go" dependency version constraint ">= 1.99": no compatible versions on "io.buildpacks.stacks.jammy" stack

The line then lists the versions it could supply, which were a short set of recent Go releases. This is the useful version of failing: the error names the constraint, where it came from (go.mod) and what is available. It also confirms that go.mod is read as a lower bound.

7. no matches for kind "ClusterLifecycle" ... ensure CRDs are installed first

kpack's release manifest ships its custom resource definitions and a ClusterLifecycle in one file. The first kubectl apply reached the custom resource before its definition was established. Waiting for the definitions and applying again fixed it.

8. Ready=False NoLatestImage: Builder has no latestImage, and a stack change nobody noticed

Two separate things, one theme. The ClusterBuilder was first reconciled before its stack was ready (stack jammy is not ready) and then sat quiet for a long time. Later, after I edited the stack, kpack reconciled the builder just before the stack's own status was updated, read the old value and did not come back; no new Build appeared. Touching the ClusterBuilder with an annotation made it read the stack again, and the STACK build started. I do not know whether this is a bug or a race I caused with how I applied things. It is what happened, and the lab's stack phase carries a touch for it.

9. ErrImagePull for an image that exists on my laptop

The pod asked for hello-go:never-loaded and the node had never been given it. The event reads failed to pull and unpack image "docker.io/library/hello-go:never-loaded". On kind, an image on the host is not an image on the node until kind load puts it there.

Frequently asked

What is a buildpack?

A module that detects whether it applies to a source directory and, if so, contributes layers to the image: a language runtime, installed dependencies, a compiled binary, a launch command. Several run in order for one build.

Do buildpacks replace Dockerfiles?

For the common case of a service in a supported language, yes, and for the platform that is the point. They do not replace a Dockerfile when you need system packages, CUDA, a scratch base or tight control over every layer.

What is the difference between pack and kpack?

pack runs a build on a machine you are sitting at, usually a laptop or a CI runner. kpack runs it inside a cluster, from an Image custom resource, and keeps rebuilding or rebasing when the source, the builder or the stack changes.

What is rebase and is it safe?

It replaces the run image layers of an existing image with newer ones from the same run image, without rebuilding. It relies on the run image keeping binary compatibility with the one it replaces, which is why it is tied to a stack id. It fixes the base. It cannot fix a vulnerable library inside your own application layers.

Is Paketo the only option?

No. Heroku and Google publish buildpacks and builders too. I used Paketo because its Go and Python buildpacks are published for both amd64 and arm64, which mattered on this Mac.

Do buildpacks work on Apple Silicon?

They worked here once everything was native: a buildpackless builder with multi-architecture buildpacks. The all-in-one Paketo builder was amd64 only and crashed under emulation, twice, in two different places.

How do I get an SBOM out of an image?

pack sbom download reads the files the build embedded: CycloneDX, SPDX and Syft formats. No need to run the image.

What if I need a system package?

You cannot run apt install the way a Dockerfile can. The routes are a buildpack that provides it, an extension (a Dockerfile fragment, still experimental in the tooling I looked at), your own builder, or a Dockerfile for that service. I did not try any of them in this lab.

Does it produce a smaller image than a Dockerfile?

I did not compare sizes and will not guess. The run image is a minimal Ubuntu base, not scratch. If the smallest possible image matters, check it for your service.

The trade-off, side by side

How to build the image:

Dockerfile pack in CI kpack in the cluster
Plus full control of every layer; everyone knows it; system packages are easy one command for every language; SBOM; rebase available; no file to maintain builds are state, not triggers; source, builder and stack changes rebuild or rebase on their own
Minus a hundred copies drift apart; base patches mean rebuilds everywhere a failure is inside a buildpack; you depend on the builder's version policy; system packages are hard another controller to run; a registry the cluster can push to quickly; build pods and credentials to manage
Where it fits one team, few services, tuned images, native libraries many services in a few languages, with a platform team an internal platform where developers should not think about builds at all

When to patch a base image:

Rebuild everything Rebase
Plus picks up fixes in your own dependencies at the same time; nothing special to trust the compiler never runs; one registry operation per image; the application layers are byte for byte what was tested
Minus every pipeline runs; every build can change something unrelated only the base changes; depends on the run image staying compatible; does nothing for your own code
Where it fits a release that was going to happen anyway a base image fix on a day nothing else should change

Neither table has a winner. In my lab the buildpack path won on rebase and on the single build step, and it lost on the first-run experience on this hardware and on how hard the failures were to read at first.

When to use which

  • Many services, a few languages, one platform team: buildpacks. Rebase alone can justify them.
  • An internal platform where developers should not write Dockerfiles: buildpacks, with kpack or a pipeline step that runs pack.
  • One team, a handful of services, tuned Dockerfiles that already work: stay on Dockerfiles.
  • System libraries, CUDA, a scratch image, unusual layer control: a Dockerfile for that service.
  • Mixed estate: buildpacks by default, a Dockerfile by exception. If a Dockerfile is in the repository root the pipeline uses it, otherwise pack. It forces nobody, and it puts the default in the right place.
  • On Apple Silicon: check the architecture of the builder before you check anything else.

Your call

For services in Go or Python on a platform I run, I would use buildpacks and keep a Dockerfile for the exceptions, mostly for rebase and for the single build path. That is for my cluster and my kind of services, not a rule for yours. Two things I would like to hear from real pipelines:

  • When a base image fix lands, what does your team do today: rebuild every image, rebase, or wait for the next release?
  • Have you gone back from buildpacks to Dockerfiles, and what was the thing that pushed you?

I am not after who is right. I want the pluses and minuses in the tables above to be visible to everyone reading, in words from real pipelines, and the comments are where that happens: https://www.linkedin.com/in/mirac-can-yilmaz

Summary

  • Cloud Native Buildpacks turn source into an OCI image without a Dockerfile, in detect, build and export phases, and record which layers belong to the base and which to the application.
  • That record is what makes rebase possible: a base image fix reaches an existing image without the compiler running. It fixes the base only.
  • The SBOM travels inside the image and can be read without running it.
  • kpack does the same from a custom resource; a stack change becomes a Build that only rebases.
  • On Apple Silicon the all-in-one Paketo builder is amd64 only and crashed under emulation. The buildpackless builder with multi-architecture buildpacks worked.
  • Most of the things that broke gave a readable error once I knew where to look: the architecture, the stack name, the CRD order, the image on the node.

Next in the series

This is post 11 of Core Skills. Previous: What Is an AWS VPC?. Next: What Is Velero?, disaster recovery on Kubernetes with Velero, backing up a cluster and restoring it somewhere else.

The code for this lab (both apps and their project.toml files, the kpack resources, the source server, the two broken sources and the scripts for every phase) is shared with Lab Access members on Buy Me a Coffee; the repo invite comes by email after you join: https://buymeacoffee.com/miraccanyilmaz/membership

About the author

Mirac Can Yılmaz

Mirac Can Yılmaz DevOps & Platform Engineer

I work as a DevOps and platform engineer with Kubernetes, GitOps (Argo CD), CI/CD and Terraform. Every post here was tried and measured in my own lab, on kind and Talos clusters: the commands, the errors and the numbers as they happened. The lab code is shared with Lab Access members on Buy Me a Coffee.

İnsanın en büyük hatalarından biri de doğru zamanı yanlış kişilerle doldurmaktır.
Charles Bukowski