You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: buildpack.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,30 @@ Any combination of the three layer types are valid for a particular layer direct
138
138
The following specifies the interface implemented by component buildpacks.
139
139
The lifecycle MUST invoke executables in component buildpacks as described in the Phase sections.
140
140
141
+
### Execution Environments
142
+
143
+
Execution environments define the context in which a buildpack-created application is intended to run. Standard values include:
144
+
-`production`: The default environment, optimized for running applications in production.
145
+
-`test`: Environment optimized for testing applications.
146
+
-`development`: Environment optimized for development workflows.
147
+
148
+
Buildpacks SHOULD adapt their behavior based on the `CNB_EXEC_ENV` environment variable during detection and build phases. This may include:
149
+
- Installing different dependencies
150
+
- Configuring different build options
151
+
- Creating different launch processes
152
+
- Providing environment-specific layers
153
+
154
+
Buildpacks MAY optimize their output based on the execution environment:
155
+
- A buildpack MAY mark processes as applicable only to specific execution environments
156
+
- A buildpack MAY create layers that are specific to certain execution environments
157
+
- A buildpack MAY use different build strategies depending on the execution environment
158
+
159
+
When the `CNB_EXEC_ENV` environment variable is not set, buildpacks MUST assume the default value of `production`.
160
+
161
+
The value of `CNB_EXEC_ENV` MUST NOT contain the character `/` as it is reserved for future use.
162
+
163
+
When a platform builds an application with a different execution environment than was used in a previous build, the platform SHOULD NOT restore layers from the previous build's image. The lifecycle MAY ignore layer metadata from previous builds with different execution environments to ensure proper environment-specific behaviors are maintained.
164
+
141
165
### Buildpack API Compatibility
142
166
Given a buildpack declaring `<buildpack API Version>` in its [`buildpack.toml`](#buildpacktoml-toml), the lifecycle:
143
167
- MUST either conform to the matching version of this specification when interfacing with the buildpack or
@@ -166,6 +190,7 @@ Executable: `/bin/detect`, Working Dir: `<app[AR]>`
166
190
|`$0`|| Absolute path of `/bin/detect` executable |
167
191
|`$CNB_BUILD_PLAN_PATH`| E | Absolute path of the build plan |
168
192
|`$CNB_BUILDPACK_DIR`| ER | Absolute path of the buildpack root directory |
193
+
|`$CNB_EXEC_ENV`| AR | Target execution environment ("production", "test", "development") |
169
194
|`$CNB_PLATFORM_DIR`| AR | Absolute path of the platform directory |
170
195
|`$CNB_PLATFORM_DIR/env/`| AR | User-provided environment variables for build |
171
196
|`$CNB_PLATFORM_DIR/#`| AR | Platform-specific extensions |
@@ -187,6 +212,7 @@ Executable: `/bin/build`, Working Dir: `<app[AI]>`
187
212
|`$CNB_LAYERS_DIR`| EIC | Absolute path of the buildpack layers directory |
188
213
|`$CNB_BP_PLAN_PATH`| ER | Relevant [Buildpack Plan entries](#buildpack-plan-toml) from detection (TOML) |
189
214
|`$CNB_BUILDPACK_DIR`| ER | Absolute path of the buildpack root directory |
215
+
|`$CNB_EXEC_ENV`| AR | Target execution environment ("production", "test", "development") |
190
216
|`$CNB_PLATFORM_DIR`| AR | Absolute path of the platform directory |
191
217
|`$CNB_PLATFORM_DIR/env/`| AR | User-provided environment variables for build |
192
218
|`$CNB_PLATFORM_DIR/#`| AR | Platform-specific extensions |
@@ -907,6 +933,7 @@ command = ["<command>"]
907
933
args = ["<arguments>"]
908
934
default = false
909
935
working-dir = "<working directory>"
936
+
exec-env = ["<execution environment>"] # Optional. If not specified, applies to all execution environments
910
937
911
938
[[slices]]
912
939
paths = ["<app sub-path glob>"]
@@ -935,6 +962,7 @@ For each process, the buildpack:
935
962
- The `args` list is a default list of arguments that may be overridden by the user [^command-args].
936
963
- MAY specify a `default` boolean that indicates that the process type should be selected as the [buildpack-provided default](https://github.com/buildpacks/spec/blob/main/platform.md#outputs-4) during the export phase.
937
964
- MAY specify a `working-dir` for the process. The `working-dir` defaults to the application directory if not specified.
965
+
- MAY specify an `exec-env` array to restrict the process to specific execution environments. If `exec-env` is not specified, the process applies to all execution environments.
938
966
939
967
[^command-args]: For versions of the Platform API that do not support overridable arguments, the arguments in `command` and `args` are always applied together with any user-provided arguments.
940
968
In general, the [Platform Interface Specification](platform.md) is ultimately responsible for launching processes; consult that specification for details.
@@ -1021,13 +1049,15 @@ name = "<dependency name>"
1021
1049
cache = false
1022
1050
1023
1051
[metadata]
1024
-
# buildpack-specific data
1052
+
exec-env = ["<execution environment>"] # Optional. If not specified, applies to all execution environments
1053
+
# other buildpack-specific data
1025
1054
```
1026
1055
1027
1056
For a given layer, the buildpack MAY specify:
1028
1057
1029
1058
- Whether the layer is cached, intended for build, and/or intended for launch.
1030
1059
- Metadata that describes the layer contents.
1060
+
- An `exec-env` array in the `[metadata]` section to restrict the layer to specific execution environments. If `exec-env` is not specified, the layer applies to all execution environments.
1031
1061
1032
1062
### buildpack.toml (TOML)
1033
1063
This section describes the 'Buildpack descriptor'.
@@ -1095,6 +1129,12 @@ The `[[buildpack.licenses]]` table is optional and MAY contain a list of buildpa
1095
1129
-`type` - This MAY use the SPDX 2.1 license expression, but is not limited to identifiers in the SPDX Licenses List.
1096
1130
-`uri` - If this buildpack is using a nonstandard license, then this key MAY be specified in lieu of or in addition to `type` to point to the license.
1097
1131
1132
+
**The buildpack execution environments:**
1133
+
1134
+
The `[[buildpack.exec-env]]` table is optional and MAY contain a list of execution environments that the buildpack supports where:
1135
+
1136
+
-`name` - This MUST specify an execution environment name (e.g., "production", "test", "development").
1137
+
1098
1138
**The buildpack SBOM:**
1099
1139
1100
1140
*Key: `sbom-formats = [ "<string>" ]`*
@@ -1123,6 +1163,8 @@ Metadata specified in `[[targets]]` is validated against the runtime and build-t
1123
1163
1124
1164
A buildpack reference inside of a `group` MUST contain an `id` and `version`. The `order` MUST include only buildpacks and MUST NOT include image extensions.
1125
1165
1166
+
A buildpack reference inside of a `group` MAY contain an `exec-env` array to specify the execution environments for which the buildpack applies.
0 commit comments