Skip to content

Commit 732fc7b

Browse files
authored
Merge pull request #416 from buildpacks/jjbustamante/0134-execution-env-platform
[Platform API] - Add Execution Environment definition
2 parents 582256c + 29d89c0 commit 732fc7b

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

platform.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ A **launcher layer** refers to a layer in the app OCI image containing the **lau
131131

132132
The **launcher** refers to a lifecycle executable packaged in the **app image** for the purpose of executing processes at runtime.
133133

134+
An **execution environment** refers to the context in which an application is intended to run. Standard values include "production", "test", and "development". Production is the default if not specified. The value MUST NOT contain the character `/` as it is reserved for future use.
135+
134136
An **image extension** refers to software compliant with the [Image Extension Interface Specification](image_extension.md). Image extensions participate in detection and execute before the buildpack build process.
135137

136138
A **stack** (deprecated, see [deprecations](#deprecations)) is a contract, implemented by a **build image** and **run image**, that guarantees properties of the **build environment** and **app image**.
@@ -402,6 +404,7 @@ Usage:
402404
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
403405
| `<build-config>` | `CNB_BUILD_CONFIG_DIR` | `/cnb/build-config` | Path to build config directory |
404406
| `<buildpacks>` | `CNB_BUILDPACKS_DIR` | `/cnb/buildpacks` | Path to buildpacks directory (see [Buildpacks Directory Layout](#buildpacks-directory-layout)) |
407+
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
405408
| `<extensions>`^ | `CNB_EXTENSIONS_DIR` | `/cnb/extensions` | Path to image extensions directory (see [Image Extensions Directory Layout](#image-extensions-directory-layout) |
406409
| `<generated>`^ | `CNB_GENERATED_DIR` | `<layers>/generated` | Path to output directory for generated Dockerfiles |
407410
| `<group>` | `CNB_GROUP_PATH` | `<layers>/group.toml` | Path to output group definition |
@@ -451,6 +454,10 @@ The lifecycle:
451454
- SHALL detect a single group from `<order>` and write it to `<group>` using the [detection process](buildpack.md#phase-1-detection) outlined in the Buildpack Interface Specification
452455
- SHALL write the resolved build plan from the detected group to `<plan>`
453456
- SHALL provide `run-image.target` data in `<analyzed>` to buildpacks according to the process outlined in the [Buildpack Interface Specification](buildpack.md).
457+
- When `CNB_EXEC_ENV` is set to a value other than the default:
458+
- The lifecycle SHALL skip buildpacks that do not support the current execution environment during detection
459+
- If all buildpacks in a group are skipped due to execution environment mismatch, the lifecycle SHALL continue to the next group in the order
460+
- This allows the platform to select buildpack groups appropriate for the target execution environment
454461

455462
When image extensions are present in the order (optional), the lifecycle:
456463
- SHALL execute all image extensions in the order defined in `<group>` according to the process outlined in the [Buildpack Interface Specification](buildpack.md).
@@ -510,6 +517,7 @@ Usage:
510517
| `<skip-layers>` | `CNB_SKIP_LAYERS` | `false` | Do not perform [layer restoration](#layer-restoration) |
511518
| `<uid>` | `CNB_USER_ID` | | UID of the build image `User` |
512519
| `<run>`** | `CNB_RUN_PATH` | `/cnb/run.toml` | Path to run file (see [`run.toml`](#runtoml-toml)) |
520+
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
513521
> ^ Only needed when using image extensions
514522
515523
> \* Only needed when using image extensions to extend the build image
@@ -552,7 +560,9 @@ Usage:
552560

553561
##### Layer Restoration
554562

555-
lifeycle MUST use the provided `cache-dir` or `cache-image` to retrieve cache contents. The [rules](https://github.com/buildpacks/spec/blob/main/buildpack.md#layer-types) for restoration MUST be followed when determining how and when to store cache layers.
563+
The lifecycle MUST use the provided `cache-dir` or `cache-image` to retrieve cache contents. The [rules](https://github.com/buildpacks/spec/blob/main/buildpack.md#layer-types) for restoration MUST be followed when determining how and when to store cache layers.
564+
565+
When a platform builds an application with a different execution environment than was used in a previous build (different value of `CNB_EXEC_ENV`), 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.
556566

557567
#### `extender` (optional)
558568

@@ -597,6 +607,7 @@ Usage:
597607
| `<plan>`* | `CNB_PLAN_PATH` | `<layers>/plan.toml` | Path to resolved build plan (see [`plan.toml`](#plantoml-toml)) |
598608
| `<platform>` | `CNB_PLATFORM_DIR` | `/platform` | Path to platform directory |
599609
| `<uid>`* | `CNB_USER_ID` | | UID of the build image `User` |
610+
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
600611

601612
> \* Only needed when extending the build image
602613
@@ -665,6 +676,7 @@ Usage:
665676
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
666677
| `<build-config>` | `CNB_BUILD_CONFIG_DIR` | `/cnb/build-config` | Path to build config directory |
667678
| `<buildpacks>` | `CNB_BUILDPACKS_DIR` | `/cnb/buildpacks` | Path to buildpacks directory (see [Buildpacks Directory Layout](#buildpacks-directory-layout)) |
679+
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
668680
| `<group>` | `CNB_GROUP_PATH` | `<layers>/group.toml` | Path to group definition (see [`group.toml`](#grouptoml-toml)) |
669681
| `<layers>` | `CNB_LAYERS_DIR` | `/layers` | Path to layers directory |
670682
| `<log-level>` | `CNB_LOG_LEVEL` | `info` | Log Level |
@@ -997,6 +1009,7 @@ Usage:
9971009
| Input | Environment Variable | Default Value | Description |
9981010
|------------------------------------|----------------------|---------------|-----------------------------------------------------------|
9991011
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
1012+
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
10001013
| `<layers>` | `CNB_LAYERS_DIR` | `/layers` | Path to layer directory |
10011014
| `<process-type>` | | | `type` of process to launch |
10021015
| `<direct>` | | | Process execution strategy |
@@ -1013,7 +1026,12 @@ The launcher:
10131026
- **If** the final path element in `$0`, matches the type of any buildpack-provided process type
10141027
- `<process-type>` SHALL be the final path element in `$0`
10151028
- The lifecycle:
1016-
- MUST select the process with type equal to `<process-type>` from `<layers>/config/metadata.toml`
1029+
- MUST select the process with type equal to `<process-type>` from `<layers>/config/metadata.toml` that is eligible for the current execution environment
1030+
- **If** no process with the requested type is eligible for the current execution environment, the lifecycle MUST fail
1031+
- A process is considered eligible for the current execution environment if:
1032+
- It has no execution environment specified in `exec-env`, OR
1033+
- Its `exec-env` includes the value of `<exec-env>`, OR
1034+
- Its `exec-env` includes the special value `"*"` which indicates compatibility with all execution environments
10171035
- MUST set `<working-dir>` to the value defined for the process in `<layers>/config/metadata.toml`, or to `<app>` if not defined
10181036
- **If** the buildpack that provided the process supports default process args
10191037
- `<direct>` SHALL be `true`
@@ -1337,6 +1355,7 @@ command = ["<command>"]
13371355
args = ["<arguments>"]
13381356
direct = false
13391357
working-dir = "<working directory>"
1358+
exec-env = ["<execution environment>"] # Optional. If not specified, applies to all execution environments. The special value "*" indicates compatibility with all execution environments. If exec-env is ["*"] or not specified, the process is eligible for all execution environments.
13401359

13411360
[[slices]]
13421361
paths = ["<app sub-path glob>"]
@@ -1345,6 +1364,9 @@ paths = ["<app sub-path glob>"]
13451364
Where:
13461365
- `id`, `version`, and `api` MUST be present for each buildpack
13471366
- `processes` contains the complete set of processes contributed by all buildpacks
1367+
- The `exec-env` field MUST be set to `["*"]` if the process applies to all execution environments
1368+
- The `exec-env` field MUST contain specific execution environment values (e.g., `["production"]`, `["test", "development"]`) if the process is restricted to certain environments
1369+
- If `exec-env` is not specified, it SHALL be treated as `["*"]` (applies to all environments)
13481370
- `slices` contains the complete set of slices defined by all buildpacks
13491371

13501372
#### `order.toml` (TOML)
@@ -1478,7 +1500,8 @@ Where:
14781500
],
14791501
"direct": false,
14801502
"working-dir": "<working-dir>",
1481-
"buildpackID": "<buildpack ID>"
1503+
"buildpackID": "<buildpack ID>",
1504+
"exec-env": ["<execution environment>"] // Array of execution environments. Use ["*"] for all environments. If omitted, defaults to ["*"]
14821505
}
14831506
],
14841507
"buildpacks": [
@@ -1528,6 +1551,7 @@ Where:
15281551
"config": {
15291552
"sha": "<config-layer-diffID>"
15301553
},
1554+
"exec-env": "<execution environment>",
15311555
"launcher": {
15321556
"sha": "<launcher-layer-diffID>"
15331557
},

0 commit comments

Comments
 (0)