What is a builder?

A builder is an OCI image containing an ordered combination of buildpacks and a build-time base image, a lifecycle binary, and a reference to a runtime base image.

The build-time base image provides the base environment for the builder (e.g., an Ubuntu Jammy OS image with build tooling) and a runtime base image provides the base environment for the app image during runtime.

builder

Under the hood a builder uses the lifecycle to run the detect phase for all the buildpacks it contains, in order, and then proceeds to run the build phase for all the buildpacks that passed detection.

This allows us to have a single builder that can detect and build various kinds of applications automatically.

For example, let’s say demo-builder contains the Python and Node buildpack. Then -

  • If your project just has a requirements.txt, demo-builder will only run the Python build steps.
  • If your project just has a package-lock.json, demo-builder will only run the Node build steps.
  • If your project has both package-lock.json and requirements.txt, demo-builder will run both the Python and Node build steps.
  • If your project has no related files, demo-builder will fail to detect and exit.