velyr-pack Experimental
Build and deploy for apps on Docker Swarm: one manifest for the image and the services, with a rollout policy that does not drop requests.
velyr-pack builds and deploys apps on Docker Swarm. You describe your app once in velyr.toml; velyr-pack builds the image with Cloud Native Buildpacks and writes the Swarm services with a rollout policy that does not drop requests or run two copies of a worker.
Why#
A Swarm stack file for a real app grows to dozens of services that differ in a command, a replica count and a memory limit, and every one of them repeats the same healthcheck, update order and restart policy. Each copy is one more place to get wrong. The image has the same problem: a Dockerfile per app, kept in step with PHP releases by hand.
velyr-pack moves both into one manifest:
- One list of processes.
web,worker,scheduler: the image declares each one, and every service runs one of them with its own arguments. - Generated services, hand-written everything else. velyr-pack only rewrites the block between
# velyr:beginand# velyr:endin your stack file. Networks, volumes, anchors and services you write by hand stay byte for byte. - The same rollout for every service of a kind. Web processes start the new task and wait for its healthcheck before stopping the old one; workers stop the old task first, so two versions never consume the same queue. Every service gets an init process.
- No Dockerfile. The
velyr-phpbuilder turns a Laravel app into an Octane on FrankenPHP image, for PHP 8.3, 8.4 and 8.5 on linux/amd64 and linux/arm64, with bases pinned by digest and updated weekly. - Drift fails CI.
velyr-pack compose -checkfails when someone edits the generated block by hand.
How it fits together#
pack build
velyr.toml ──────► velyr-php-builder ──────► app image
[processes] /cnb/process/web
[envs] /cnb/process/worker
│ │
│ velyr-pack compose ▼
└──────────────► stack.yml ──────► docker stack deploy
# velyr:begin
# velyr:endThe builder reads [processes] to declare the image entrypoints. The CLI reads [envs] to write the services that run them. Both read the same file, so the image and the stack cannot disagree on what a process is.
A quick look#
[processes.web]
command = ["php", "artisan", "octane:start", "--server=frankenphp", "--host=0.0.0.0", "--port=8000"]
health = { path = "/up", port = 8000, start_period = "60s" }
[processes.worker]
command = ["php", "artisan", "queue:work"]
[envs.production]
file = "stack.yml"
image = "cnb"
service_extends = ["*app"]
cpus = "0.5"
memory = "512M"
services = [
{ name = "web", process = "web", replicas = 2, cpus = "2", memory = "1G" },
{ name = "worker", process = "worker", args = ["--queue=default"] },
{ name = "worker-mail", process = "worker", args = ["--queue=mail"] },
]$ pack build ghcr.io/you/shop --builder ghcr.io/velyrlabs/velyr-php-builder:v0.1.0-alpha.4-php8.5
$ velyr-pack compose production # writes the services into stack.yml
$ docker stack deploy -c stack.yml shopThe getting started guide walks through it end to end, and examples/laravel is a complete app layout.
Install#
CLI. Each GitHub release publishes static binaries for linux and darwin, amd64 and arm64, with a SHA256SUMS file:
$ curl -fsSLO https://github.com/velyrlabs/velyr-pack/releases/download/v0.1.0-alpha.4/velyr-pack-linux-amd64
$ curl -fsSLO https://github.com/velyrlabs/velyr-pack/releases/download/v0.1.0-alpha.4/SHA256SUMS
$ sha256sum --ignore-missing -c SHA256SUMS
$ install -m 0755 velyr-pack-linux-amd64 /usr/local/bin/velyr-packOr build it with Go 1.24 or newer:
$ go install github.com/velyrlabs/velyr-pack/cmd/velyr-pack@v0.1.0-alpha.4Builder. Nothing to install besides pack. The images are on ghcr.io/velyrlabs; see the velyr-php builder for the tags.
Status#
| Part | Status |
|---|---|
velyr.toml and velyr-pack compose | Used in production. The format can still change before 1.0. |
velyr-php builder | Used in production for Laravel Octane on FrankenPHP. |
velyr-pack orbital | Prints entries for an external autoscaler; the autoscaler is not part of the repository. |
| Other languages | Not started. The CLI and manifest do not depend on PHP. |
Source#
velyr-pack is on GitHub under the Apache-2.0 license. Maintainers publish releases as described in Releasing; changes are listed in the changelog.