Skip to content

Latest commit

 

History

History
122 lines (80 loc) · 4.39 KB

0109-build-config.md

File metadata and controls

122 lines (80 loc) · 4.39 KB

Meta

Summary

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.

Definitions

  • CNB environment directory: A directory that follows the conventions as defined here
  • Operator: Owner of builders and stacks. See CNB Operator guide.

Motivation

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.

What it is

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.

How it Works

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.

Migration

N/A

Drawbacks

  • Increased complexity in sourcing of environment variables.

Alternatives

Implementing at a Buildpack level

See paketo-buildpacks/rfcs#241

Prior Art

Unresolved Questions

N/A

Spec. Changes (OPTIONAL)

Addition of the definition of the above directory in the Platform specification i.e. -

  • CNB_BUILD_CONFIG_DIR
  • /cnb/build-config/