Concepts Experimental

Processes, environments, services, image modes, and how the image and the stack file stay in step.

velyr-pack has three ideas: processes (what the image can run), environments (one per Swarm stack file) and services (one per Swarm service, each running a process). This page explains how they relate and what velyr-pack does with each.

Processes#

A process is a command the app can run, declared once in [processes.<name>]:

toml
[processes.worker]
command = ["php", "artisan", "queue:work"]
grace = "60s"

The command is a list, run without a shell. When a velyr builder builds the image, every process becomes an executable at /cnb/process/<name> (a CNB process type). Arguments passed to that executable are appended to the command, which is what lets one process back many services:

console
$ docker run --entrypoint /cnb/process/worker shop --queue=mail
# runs: php artisan queue:work --queue=mail

There are two kinds of process, and the kind decides how a service is rolled out:

KindHow you declare itRollout
webthe process has healthstart-first, gated by an HTTP healthcheck
workerno healthstop-first, no healthcheck

If exactly one process has health, it is the image's default process: docker run <image> starts it. With zero or several web processes there is no default and every service names its entrypoint.

Environments#

An environment is one Swarm stack file and the services velyr-pack writes into it:

toml
[envs.production]
file = "stack.yml"
image = "cnb"
cpus = "0.5"
memory = "512M"
services = [ ... ]

Most apps have one environment per stack: production, staging, or one per group of services when a stack gets too big for one file. Every environment carries the defaults its services inherit (replicas, cpus, memory) and the YAML anchors they extend.

image says how the stack runs the processes:

  • cnb: the image was built by a velyr builder. Each service sets entrypoint: ["/cnb/process/<name>"] and puts its args in command:. Services must use a process.
  • dockerfile (the default): any image. The service's command: is the process command plus its args, and a service may set a raw command instead of a process. Use it to adopt velyr-pack before you move to the builder.

Services#

A service is one Swarm service. It runs a process (or, with image = "dockerfile", a raw command) and sets what differs from its siblings:

toml
services = [
  { name = "worker", process = "worker", args = ["--queue=default"], replicas = 3 },
  { name = "worker-mail", process = "worker", args = ["--queue=mail"], memory = "256M" },
]

Everything else comes from the process (healthcheck, grace period, rollout order) and from the environment (replicas, limits, anchors). The result is that a service entry is usually one line, and two services of the same kind can only differ where the manifest says they do.

The generated block#

velyr-pack compose <env> renders the environment's services and writes them into its stack file, between two markers:

yaml
services:
  # velyr:begin generated by velyr-pack from velyr.toml (env production): edit velyr.toml, then run velyr-pack compose production
  web:
    ...
  # velyr:end

  redis:
    image: redis:7-alpine

The first run turns the bare # velyr:begin into the comment above. Everything outside the block is yours and is kept byte for byte: anchors (x-app: &app), networks, volumes, configs, secrets and hand-written services. velyr-pack never parses the YAML; it only replaces the lines between the markers.

That split is deliberate. The parts every service shares and that rarely change (image, environment, networks, logging) stay in YAML anchors you write once. The parts that are repetitive and easy to get wrong (healthcheck, update and rollback config, limits, init) are generated.

velyr-pack compose -check <env> renders the block and fails when the file differs, so CI catches hand edits and manifests that changed without regenerating.

The image#

The velyr-php builder reads the same velyr.toml at build time and runs velyr-pack launch to write the image's process list. That is the link between the two halves:

  • the image declares /cnb/process/worker because [processes.worker] exists;
  • the stack runs /cnb/process/worker because a service says process = "worker".

Rename a process and both change in the same commit. A service that names a process the manifest does not declare fails validation before anything is written.

What velyr-pack does not do#

  • It does not deploy. It writes the stack file; docker stack deploy, Dokploy, Portainer or your own script applies it.
  • It does not manage the YAML around the block. Networks, volumes, configs, secrets and anchors are yours.
  • It does not autoscale. scale and velyr-pack orbital print entries for an external autoscaler; nothing in this repository reads them.
  • It does not template values. ${IMAGE_TAG} and other variables in the stack file are resolved by whatever deploys it.