Buildpacks allow you to convert your source code into a secure, efficient, production ready container image.
Buildpacks provide framework and runtime support for applications. Buildpacks examine your apps to determine all the dependencies it needs and configure them appropriately to run on any cloud.
Each buildpack comprises of two phases -
The detect
phase runs against your source code to determine if the buildpack is applicable or not. Once a buildpack is detected
to be applicable, it proceeds to the build
stage. If the project fails detection
the build
stage for a specific buildpack is skipped.
For example:
requirements.txt
or a setup.py
file passpackage-lock.json
file to passThe build
phase runs against your source code to -
For example:
pip install -r requirements.txt
if it detected a requirements.txt
filenpm install
if it detected a package-lock.json
fileBuilders
are an ordered combination of buildpacks
with a base build
image, a lifecycle, and reference to a run image
. They take in your app
source code and build the output app image
. The build
image provides the base environment for the builder
(for eg. an Ubuntu Bionic OS image with build tooling) and a run
image provides the base environment for the app image
during runtime. A combination of a build
image and a run
image is called a stack
.
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 of 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 -
requirements.txt
, demo-builder
will only run the Python build
steps.package-lock.json
, demo-builder
will only run the Node build
steps.package-lock.json
and requirements.txt
, demo-builder
will run both the Python and Node build
steps.demo-builder
will fail to detect
and exit.