Finds an ordered group of buildpacks to use during the build phase.
Detection is the first phase of the Lifecycle. It’s done by the
In this phase, the detector looks for an ordered group of buildpacks that will be used during the build phase.
The detector is invoked in the build environment without any required arguments and it cannot run with root privileges.
One of the input files is
order.toml and two of its output files are
Unless some flags are passed in, the detector will use the following defaults:
The full list of flags and their defaults can be found here.
order.toml contains a list of groups, each group itself contains a list of buildpacks.
The detector reads the
order.toml and looks for the first group that passes the detection process.
If all of the groups fail, the detection process fails.
Each buildpack in each group is marked as either optional or as required. In order to pass the detection process, two conditions must be satisfied:
plan.toml) with all of the requirements of the group’s buildpacks.
The first group that passes both steps is written to
group.toml and its build plan is written to
Note: If the detect script of an optional buildpack failed, the group can still pass the detection process and be the “chosen” group. In order for that to happen, there should be at least one (required or optional) buildpack in this group that passes the detect script successfully.
The buildpacks of the “chosen” group will be written to
group.toml if they pass the step of creating
plan.toml. They are written in the same order as they appear in
order.toml after filtering out all of the (optional) buildpacks whose detect script failed.
Each buildpack can define two lists with provided and required dependencies (or several pairs of lists separated by
or). These lists (if they aren’t empty) are called a build plan and they are part of the output of each buildpack’s detect script.
The detector reads the build plans of the buildpacks of the “chosen” group (after filtering out the buildpacks whose detect script failed). It goes over all of the options and tries to create a file with a list of entries, each with provides and requires lists, that fulfills all of the buildpacks requirements. Each of the options is called a trial, and this output file is called
The two restrictions for provides and requires are:
If at least one of the above failed on a required buildpack, the trial fails and the detector will look for the next trial. If at least one of the above failed on an optional buildpack, this buildpack should be excluded from the final plan. If all of the trials fail, the group fails (and the detector moves on to the next group).
||Platform API incompatibility error|
||Buildpack API incompatibility error|
||Generic lifecycle errors|
||All buildpacks groups have failed to detect w/o error|
||All buildpack groups have failed to detect and at least one buildpack has errored|
||Detection-specific lifecycle errors|
The following file is responsible for the detection command: https://github.com/buildpacks/lifecycle/blob/main/cmd/lifecycle/detector.go.
The public functions in the above file are being called by the
Run function in the following file: https://github.com/buildpacks/lifecycle/blob/main/cmd/command.go
The spec of the detector can be found here.