Skip to content

Conversation

@jjbustamante
Copy link
Member

@jjbustamante jjbustamante commented May 7, 2025

RFC-0134

  1. Added Execution Environment definition:
    - Added a definition for "execution environment" in the CNB Terminology section
    - Defined standard values: production (default), test, and development
  2. Environment variables:
    - Added CNB_EXEC_ENV to detector, builder, and launcher inputs
    - Documented that it defaults to "production" when not specified
  3. Process selection logic:
    - Updated the launcher's process selection logic to respect execution environments
    - Added rules to determine when a process is eligible for the current environment
    - Specified that the launcher must fail if a requested process is not available for the current environment
  4. Data formats:
    - Updated metadata.toml to include exec-env in the process definitions
    - Added execution environment to the io.buildpacks.build.metadata JSON format
    - Added execution environment to the io.buildpacks.lifecycle.metadata JSON format
  5. Process eligibility:
    - Defined that a process is eligible for an execution environment if:
    • It has no execution environment specified, OR
    • Its exec-env list includes the current execution environment

These changes enable platforms to specify which execution environment an application should be built for and run in, allowing buildpacks to provide different behaviors for different
environments (production, test, development).

Resolves #420

Signed-off-by: Juan Bustamante <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
@jjbustamante jjbustamante marked this pull request as ready for review May 7, 2025 02:11
@jjbustamante jjbustamante requested a review from a team as a code owner May 7, 2025 02:11
@jjbustamante jjbustamante added this to the Platform 0.15 milestone May 7, 2025
| `<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?

@natalieparellano
Copy link
Member

This should be re-pointed at platform/0.15

| `<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?

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 ?

…able is now included in the restorer inputs table.

 2. ✅ Added CNB_EXEC_ENV to the extender phase - The environment variable is now included in the extender inputs table.
 3. ✅ Clarified buildpack/group skipping behavior - Added clear documentation in the detector section explaining how the lifecycle handles buildpacks and groups when execution
  environments don't match.
 4. ✅ Updated launch metadata recording - Modified the metadata.toml documentation to specify that exec-env should use ["*"] for processes that apply to all environments, with clear
  guidance that omitted values default to ["*"].

Signed-off-by: Juan Bustamante <[email protected]>
@jkutner jkutner merged commit 732fc7b into main Nov 13, 2025
1 check passed
@jkutner jkutner deleted the jjbustamante/0134-execution-env-platform branch November 13, 2025 22:42
@hone hone mentioned this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC 0134] Execution Environments

6 participants