- Name: Build config
- Start Date: 2022-08-29
- Author(s): samj1912
- Status: Approved
- RFC Pull Request: rfcs#230
- CNB Pull Request: (leave blank)
- CNB Issue: buildpacks/lifecycle#956, buildpacks/spec#330, buildpacks/docs#531
- Supersedes: (put "N/A" unless this replaces an existing RFC, then link to that RFC)
This RFC proposes an easy way to configure build images to allow specifying a /cnb/build-config
CNB environment directory that allows updating the Buildpack detect
and build
environment based on the directory.
- CNB environment directory: A directory that follows the conventions as defined here
- Operator: Owner of builders and stacks. See CNB Operator guide.
Often times, especially in enterprise settings, organizations often have to update the buildpacks to use internal mirrors, proxies and other settings which can be configured easily with environment variables.
Some examples include -
GOPROXY
PIP_INDEX_URL
npm_config_registry
BUNDLE_MIRROR__URL
The buildpack logic in the Buildpacks largely remains the same, except these environment variables might need to be injected during the build
and detect
phases.
The environment variables may ideally also take precendence over any user provided values to ensure that the operators have full control over their builders.
The RFC proposes the introduction of the following directory /cnb/build-config/env
in build images. The directory follows the same convention as a CNB environment directory
. The notable difference is that the environment variables sourced from this directory are applied AFTER processing the user-provided platform environment variables i.e. they should have the highest precedence. These variables should be available during both detect
and build
phases (and the generate
phase in the future).
The operator can define this directory in the build image under /cnb/build-config
or CNB_BUILD_CONFIG_DIR
if defined.
Reference implementation available at https://github.com/buildpacks/lifecycle/pull/899/files
Examples -
Buildpack value: FOO=test
Build config: FOO.default=another-value
Final value: FOO=test
Buildpack value: FOO=test
Build config: FOO.append=another-value, FOO.delim=:
Final value: FOO=test:another-value
Buildpack value: FOO=test
Build config: FOO.override=another-value
Final value: FOO=another-value
Buildpack value: FOO=test
Platform Enviroment varaible: FOO=value
Build config: FOO=another-value
Final value: FOO=value
Platform Enviroment varaible: FOO=value
Build config: FOO.override=another-value
Final value: FOO=another-value
Platform Enviroment varaible: FOO=value
Build config: FOO.prepend=another-value, FOO.delim=:
Final value: FOO=another-value:value
Platform Enviroment varaible: FOO=value
Build config: FOO.append=another-value, FOO.delim=:
Final value: FOO=value:another-value
In case a buildpack uses clear-env=true
then it is up to the buildpack will not see user provided platform values unless it looks in the platform directory and resolve the user provided platform values against the values set by previous buildpacks and the build config.
N/A
- Increased complexity in sourcing of environment variables.
See paketo-buildpacks/rfcs#241
- See paketo-buildpacks/rfcs#241 and
- See the CNB BAT meeting. https://youtu.be/e8FgLwVN5VQ?t=1153
N/A
Addition of the definition of the above directory in the Platform specification i.e. -
CNB_BUILD_CONFIG_DIR
/cnb/build-config/