Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand "Specify process types" page #737

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ One of the benefits of buildpacks is that they are multi-process - an image can

<!--more-->

A `process type` is a named process definition, contributed by a buildpack at build-time and executed by the launcher at run-time.
Buildpacks declare process types during the build phase by writing entries into `<layers>/launch.toml`.

## Key Points
Copy link
Member

Choose a reason for hiding this comment

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

This is a great translation of the spec into something more consumable by buildpack authors.


For each process, the buildpack:

* MUST specify a `type`, an identifier for the process, which:
* MUST NOT be identical to other process types provided by the same buildpack.
* MUST only contain numbers, letters, and the characters `.`, `_`, and `-`.
* MUST specify a `command` list such that:
* The first element of `command` is a path to an executable or the file name of an executable in `$PATH`.
* Any remaining elements of `command` are arguments that are always passed directly to the executable [^command-args].
* MAY specify an `args` list to be passed directly to the specified executable, after arguments specified in `command`.
* The `args` list is a default list of arguments that may be overridden by the user [^command-args].
* 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.
* MAY specify a `working-dir` for the process. The `working-dir` defaults to the application directory if not specified.

## Implementation Steps

Processes are added to the `launch.toml` file in the `<layers>/<layer>` directory as follows:

```toml
[[processes]]
type = "<process type>"
command = ["<command>"]
args = ["<arguments>"]
default = false
working-dir = "<working directory>"
```

### Examples

Let's see how this works. We will specify a process type that allows a debugger to attach to our application.

To enable running the debug process, we'll need to have our buildpack define a "process type" for the worker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The [buildpacks `exec.d` interface](https://github.com/buildpacks/spec/blob/main

2. Script Behavior:
* **Inputs**
*A third open file descriptor. File descriptors are integers used by a process to uniquely identify opened files; pre-opened file descriptors are usually 0 for stdin, 1 for stdout and 2 for stderr. The third open file descriptor is inherited from the calling process.
* A third open file descriptor. File descriptors are integers used by a process to uniquely identify opened files; pre-opened file descriptors are usually `0` for `stdin`, `1` for `stdout` and `2` for `stderr`. The third open file descriptor is inherited from the calling process.
* **Outputs**
* Valid TOML describing environment variables in the form of key=value pairs. These variables are added to the application's runtime environment. The content should be written to file descriptor 3 (see examples for how to do this).
* Exit Code: The scripts should exit with a status code of `0` to indicate success. A non-zero exit code will indicate an error and prevent the application from launching.
Expand Down
Loading