One of the benefits of buildpacks is that they are multi-process - an image can have multiple entrypoints for each operational mode.
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
.
For each process, the buildpack:
type
, an identifier for the process, which:
.
, _
, and -
.command
list such that:
command
is a path to an executable or the file name of an executable in $PATH
.command
are arguments that are always passed directly to the executable [^command-args].args
list to be passed directly to the specified executable, after arguments specified in command
.
args
list is a default list of arguments that may be overridden by the user [^command-args].default
boolean that indicates that the process type should be selected as the buildpack-provided default during the export phase.working-dir
for the process. The working-dir
defaults to the application directory if not specified.Processes are added to the launch.toml
file in the <layers>/<layer>
directory as follows:
[[processes]]
type = "<process type>"
command = ["<command>"]
args = ["<arguments>"]
default = false
working-dir = "<working directory>"
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.
We’ll need to create a launch.toml
file in the buildpack layers directory:
# ...
cat > "${CNB_LAYERS_DIR}/launch.toml" << EOL
# our web process
[[processes]]
type = "web"
command = ["node", "app.js"]
default = true
# our debug process
[[processes]]
type = "debug"
command = ["node", "--inspect", "app.js"]
EOL
# ...
After building the application, you should then be able to run your new NodeJS debug process:
docker run --rm --entrypoint debug test-node-js-app
and see the debug log output:
Debugger listening on ws://127.0.0.1:9229/