Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ A **launcher layer** refers to a layer in the app OCI image containing the **lau

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

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.

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.

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**.
Expand Down Expand Up @@ -402,6 +404,7 @@ Usage:
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
| `<build-config>` | `CNB_BUILD_CONFIG_DIR` | `/cnb/build-config` | Path to build config directory |
| `<buildpacks>` | `CNB_BUILDPACKS_DIR` | `/cnb/buildpacks` | Path to buildpacks directory (see [Buildpacks Directory Layout](#buildpacks-directory-layout)) |
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems fine to me, but I'm looking at this comment from the RFC and I don't see that specified anywhere. Are we expecting the lifecycle to skip over buildpacks or groups that don't match the current environment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. the question is if we want to skip an entire group if one of the buildpack doesn't match the env. We need @hone to chime in there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkutner @hone @natalieparellano here is a proposal

- When `CNB_EXEC_ENV` is set and differs from a previous build's execution environment:
  - The lifecycle SHALL skip buildpacks that do not support the current execution environment
  - If all buildpacks in a group are skipped due to execution environment mismatch, the lifecycle SHALL continue to the next group in the order
  - The lifecycle SHOULD NOT restore layers from previous builds with different execution environments

Or do we want to skip the entire group?

| `<extensions>`^ | `CNB_EXTENSIONS_DIR` | `/cnb/extensions` | Path to image extensions directory (see [Image Extensions Directory Layout](#image-extensions-directory-layout) |
| `<generated>`^ | `CNB_GENERATED_DIR` | `<layers>/generated` | Path to output directory for generated Dockerfiles |
| `<group>` | `CNB_GROUP_PATH` | `<layers>/group.toml` | Path to output group definition |
Expand Down Expand Up @@ -451,6 +454,10 @@ The lifecycle:
- 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
- SHALL write the resolved build plan from the detected group to `<plan>`
- SHALL provide `run-image.target` data in `<analyzed>` to buildpacks according to the process outlined in the [Buildpack Interface Specification](buildpack.md).
- When `CNB_EXEC_ENV` is set to a value other than the default:
- The lifecycle SHALL skip buildpacks that do not support the current execution environment during detection
- If all buildpacks in a group are skipped due to execution environment mismatch, the lifecycle SHALL continue to the next group in the order
- This allows the platform to select buildpack groups appropriate for the target execution environment

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

> \* Only needed when using image extensions to extend the build image
Expand Down Expand Up @@ -552,7 +560,9 @@ Usage:

##### Layer Restoration

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.
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.

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.

#### `extender` (optional)

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

> \* Only needed when extending the build image

Expand Down Expand Up @@ -665,6 +676,7 @@ Usage:
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
| `<build-config>` | `CNB_BUILD_CONFIG_DIR` | `/cnb/build-config` | Path to build config directory |
| `<buildpacks>` | `CNB_BUILDPACKS_DIR` | `/cnb/buildpacks` | Path to buildpacks directory (see [Buildpacks Directory Layout](#buildpacks-directory-layout)) |
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want CNB_EXEC_ENV in restorer as well. In order to do things like skip cache restore.

Extender also needs it I would think?

| `<group>` | `CNB_GROUP_PATH` | `<layers>/group.toml` | Path to group definition (see [`group.toml`](#grouptoml-toml)) |
| `<layers>` | `CNB_LAYERS_DIR` | `/layers` | Path to layers directory |
| `<log-level>` | `CNB_LOG_LEVEL` | `info` | Log Level |
Expand Down Expand Up @@ -997,6 +1009,7 @@ Usage:
| Input | Environment Variable | Default Value | Description |
|------------------------------------|----------------------|---------------|-----------------------------------------------------------|
| `<app>` | `CNB_APP_DIR` | `/workspace` | Path to application directory |
| `<exec-env>` | `CNB_EXEC_ENV` | `production` | Target execution environment. Standard values: "production", "test", "development". |
| `<layers>` | `CNB_LAYERS_DIR` | `/layers` | Path to layer directory |
| `<process-type>` | | | `type` of process to launch |
| `<direct>` | | | Process execution strategy |
Expand All @@ -1013,7 +1026,12 @@ The launcher:
- **If** the final path element in `$0`, matches the type of any buildpack-provided process type
- `<process-type>` SHALL be the final path element in `$0`
- The lifecycle:
- MUST select the process with type equal to `<process-type>` from `<layers>/config/metadata.toml`
- MUST select the process with type equal to `<process-type>` from `<layers>/config/metadata.toml` that is eligible for the current execution environment
- **If** no process with the requested type is eligible for the current execution environment, the lifecycle MUST fail
- A process is considered eligible for the current execution environment if:
- It has no execution environment specified in `exec-env`, OR
- Its `exec-env` includes the value of `<exec-env>`, OR
- Its `exec-env` includes the special value `"*"` which indicates compatibility with all execution environments
- MUST set `<working-dir>` to the value defined for the process in `<layers>/config/metadata.toml`, or to `<app>` if not defined
- **If** the buildpack that provided the process supports default process args
- `<direct>` SHALL be `true`
Expand Down Expand Up @@ -1337,6 +1355,7 @@ command = ["<command>"]
args = ["<arguments>"]
direct = false
working-dir = "<working directory>"
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this align with the following?

Documented that it defaults to "production" when not specified

I know the default input for the phases would be production when not set - I guess the buildpack could produce processes for production , test or omit the value in its launch.toml.

Is lifecycle going to record these launch toml values as * or omit? I would think *. I don't see a reason to omit values in this file/metadata.json

Copy link
Member Author

@jjbustamante jjbustamante Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree that if not specified, we should record * in the launch toml. @hone ?


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

#### `order.toml` (TOML)
Expand Down Expand Up @@ -1478,7 +1500,8 @@ Where:
],
"direct": false,
"working-dir": "<working-dir>",
"buildpackID": "<buildpack ID>"
"buildpackID": "<buildpack ID>",
"exec-env": ["<execution environment>"] // Array of execution environments. Use ["*"] for all environments. If omitted, defaults to ["*"]
}
],
"buildpacks": [
Expand Down Expand Up @@ -1528,6 +1551,7 @@ Where:
"config": {
"sha": "<config-layer-diffID>"
},
"exec-env": "<execution environment>",
"launcher": {
"sha": "<launcher-layer-diffID>"
},
Expand Down