Cloudverg Console
PricingDocsSign in
Docs menu

VergShip

Apps: deploy, switch and roll back

An app is a Node.js program in a Git repository. You describe it once in a verg.toml in that repository, sign the description with your operator key, and the server does the rest: it fetches the commit you name, builds it at low priority, runs your release tasks, starts it beside the old release, and moves visitors over only when the new one answers its health path. Rolling back is one command to a release the server kept.

From nothing to a live app

  1. Root on the server allows apps, naming which ones (or all). Without --apps the app verbs stay off.
    sudo verg-agent allow operations --operator owner-mac ed25519:... --apps shopfront
  2. Once, add one line to the server's main Caddyfile, so Caddy reads the sites VergShip writes. VergShip never edits that file.
    import /etc/caddy/verg.d/*.caddy
  3. Write verg.toml in the repository and check it. The command prints the exact spec your key will sign and its SHA-256.
    verg app check
  4. Sign it and make the app. The server makes two system users for it, its folders, and a deploy key, and prints the public half.
    verg app create web-1
  5. Add that key to the repository as a read-only deploy key (on GitHub: Settings, Deploy keys, leave "Allow write access" off). The private half never leaves the server.
  6. Deploy a commit that is on the branch. Without --commit the CLI uses the HEAD of the repository you are in.
    verg app deploy web-1 shopfront --commit 3f2a9c...

The verg.toml

This is a small, documented subset of TOML: comments, key = value with strings, whole numbers, true and false and lists of those, [table] and [[list of tables]]. Inline tables, dotted keys, dates and multi-line strings are not read, and a key that is not listed here is an error, so a typo never passes quietly.

name = "shopfront"
repo = "[email protected]:example/shopfront.git"
host_key = "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"
branch = "main"

[build]
commands = ["npm ci", "npm run build"]
env = ["NEXT_PUBLIC_SITE=https://shop.example.com"]

[release]
commands = ["node scripts/migrate.mjs"]

[run]
command = "node .next/standalone/server.js"
port = 3100
health = "/healthz"
memory = "1G"
storage = [".next/cache"]
env = ["SITE_URL=https://shop.example.com"]

[site]
hosts = ["shop.example.com", "www.shop.example.com"]
blocked = ["/admin"]

[[timer]]
name = "tick"
every = "1m"
path = "/api/cron/tick"
KeyWhat it doesDefault and limits
nameThe app's name. It becomes the system user verg-app-NAME.Required. Lower case letters, digits and single dashes, up to 21 characters.
kindWhat kind of app it is.node, the only kind so far.
repoWhere the code is. An https:// address, ssh://user@host/path, or git@host:owner/repo.git.Required.
host_keyThe server's own key line, so the node never trusts a key it was not told. ssh-keyscan -t ed25519 github.com prints it.Required for an ssh repository.
branchOnly commits on this branch are built. The node fetches the branch itself and checks the commit is in its history.main
[build] commandsWhat to run to build, in order. Each is one program and its words.Up to 12.
[build] envBuild values such as NEXT_PUBLIC_*, as NAME=value. They are not secret.Names in capitals; values use letters, digits and . _ : / @ + , = -.
[release] commandsRelease tasks, such as a database migration. They run after the build and before the switch, as the app's own user with its environment. A failure stops the deploy and nothing switches.Up to 12.
[run] commandHow to start the app. It must listen on $PORT on 127.0.0.1, which Next.js does when HOSTNAME is set, as VergShip sets it.Required.
[run] portThe first of two ports, one for each slot. The second is this port plus one.1024 to 65533. Required.
[run] health, health_timeoutThe path the new release must answer with a status from 200 to 399, three times in a row, and how many seconds it has./, 60 seconds (5 to 600).
[run] memory, cpu, tasksLimits. Memory is a hard cap, with a soft limit at 90% first. cpu is the CPU weight against other units.1 GB, 100, 512. Memory is megabytes (1024) or "1G".
[run] storageFolders in the release the app may write, such as .next/cache. Each becomes a link to the app's own storage, which stays across releases. Nothing else in a release is writable.Up to a few levels deep, relative.
[run] overlap, drainWith overlap the new release starts beside the old one and the old one drains for drain seconds. Set overlap = false for an app that must never run twice: the old one stops first, and there are a few seconds with no answer.true, 30 seconds (0 to 300).
[run] envPublic values for the app, as NAME=value. PORT, HOSTNAME, HOME, PATH and names starting VERG_ or LD_ are VergShip's.Names in capitals.
[run] cron_header, cron_envThe header a timer sends its secret in, and the variable the app reads that secret from.x-cron-secret, CRON_SECRET
[site] hostsThe addresses Caddy answers for. http://localhost:8080 style addresses are fine for a local check.Up to 8.
[site] cloudflareBehind Cloudflare, only Cloudflare's addresses may reach the site, so the visitor's address in the header Cloudflare sets can be believed. Anything else is answered 403.true. Set false for a name that is not proxied.
[site] tunnelAlso lets this machine itself reach the site, for a Cloudflare tunnel (cloudflared) that runs here. Any process on this machine can then set the visitor address the app sees (loopback is trusted), so on a shared box an app must not rely on that address for security. A unix-socket origin for the tunnel is the later fix.false. Only with cloudflare = true.
[site] max_body, blockedThe largest request body in megabytes, and path prefixes Caddy answers with 404 itself.25 MB (1 to 1024).
[[timer]]name; every ("10m", "1h", "1d") or at ("03:00", with tz, UTC unless you name a zone); and path (a POST to the app with the secret header) or run (a command from the release).Up to 12.

A command is one program and its words, separated by single spaces, from the letters, digits and . _ : / @ + = , -. There is no shell: &&, pipes, quotes, $(...) and redirects are refused when you check the file. When a step needs more than that, put it in a script in the repository and run node scripts/step.mjs.

What a deploy does

  1. Fetch. The server fetches the branch as the app's fetch user (its deploy key is that user's alone, not root's and not the build's), from the host key you named, and checks the commit is in the branch's history (git merge-base --is-ancestor). A commit that is only on another branch, or that was removed by a force push, is refused.
  2. Build. The commit is unpacked into a new release folder and built by the app's build user at the lowest priority (nice 19, CPU and disk weight 20, a memory cap, one heavy step at a time on the machine). It has no secrets beyond the build values in the spec.
  3. Seal. Every file's SHA-256 and every link go in a manifest the server signs with its own key, next to the commit's id. The release then belongs to root and nothing can change it. A release that holds a file with a second name (a hard link, which pnpm's store makes) or a set-user-id file is refused, so use npm or yarn.
  4. Release tasks run as the app's user. A failure ends the deploy; the new release is removed and nothing switched.
  5. Switch. Each app has two slots, verg-app-NAME@a and @b. The release starts in the one that is not live. When its health path answers three times in a row, Caddy is told about it (validated first, then a graceful reload), the old slot drains and stops. If the new one never gets healthy, or Caddy refuses the site, the old release keeps running and the answer says why.
  6. The newest five releases are kept, and never the live one or the one before it.

The deploy is answered when it ends, with each step and its time. A request that takes minutes does not block others: you can read the logs while it runs.

Roll back

verg app rollback web-1 shopfront                 # to the release before the live one
verg app rollback web-1 shopfront --release 20261130T1102Z-1a2b3c4

The server checks the kept release's files against the manifest it signed, then switches the same way a deploy does. A release whose files changed since it was sealed is refused. A database is not rolled back: code goes back, data stays where it is.

What runs as whom

WhatRuns asCan write
The agent's own work (making users, writing units and site files, fetching, sealing, reloading Caddy after caddy validate)root, in a short-lived unit with ProtectSystem=strictThe app's folders, /etc/verg/apps, the unit files and /etc/caddy/verg.d
The fetch and the unpacking of the commitverg-fetch-NAME, which owns the local copy of the repository and the deploy keyIts own folder only
The buildverg-build-NAME, in a unit with NoNewPrivileges, ProtectSystem=strict, ProtectHome, a private /tmp, nice 19Its release folder and its cache folder
Release tasks, the app, timersverg-app-NAME, with the same protections, the limits from the spec and no capabilitiesIts storage folder only

The unit is written from one template on the machine; the console sends values and never unit text. The folders: /srv/verg/apps/NAME (releases, slots, storage, the current link) and /etc/verg/apps/NAME (the signed spec, the environment, the deploy key, timer files).

Secrets

Never put a real secret in verg.toml. The env and build.env values of the spec are public: they are shown on the app's page and returned by the API. An app's secrets come from one of two places on the server, and the app has one env file, /etc/verg/apps/NAME/env, written from the spec's values, then the secrets, then the timer secret. The best place is a sealed version: verg secret push NODE NAME --env-file .env seals it on your computer to the server's own age key, and the server keeps it as secrets.env (see Sealed secrets). Without one, the secrets are what root keeps in /etc/verg/apps/NAME/secrets.local, one NAME=value per line. When both exist, the sealed version wins and secrets.local is not read. Either way the env file is readable by the app's own group only, and nothing sends a value to the console. A timer secret is made on the server when the app is made and never leaves it.

Timers and logs

A timer is a systemd timer and a one-shot service run as the app's user. A path timer posts to the live slot with the secret header, so the app checks it the way it checks any cron call (the fleet's /api/cron/* pattern). verg app timer web-1 shopfront tick runs one now.

verg app logs web-1 shopfront asks the server for the last lines of the app (--source app), of its timers, or of its last deploy. Before a line leaves the machine, every secret value of the app is replaced with ***. That covers the values in secrets.env, in secrets.local, the timer secret, and every line of eight characters or more of the app's secret files. A secret shorter than four characters is not masked, since it would damage ordinary lines.

What can be asked

VerbKindWhat the server does
app.logsReadsThe last lines of an app's logs, or of its last deploy, with every secret value of the app hidden before a line leaves the machine.
app.createChanges the specRecords a signed app spec on the machine, makes the app's users and folders, and a deploy key whose public half you add to the repository. Nothing runs yet. It answers when it finishes, which can take minutes.
app.specChanges the specReplaces the signed spec of an app: build, run, limits, sites, timers. The next deploy uses it; sites and timers change at once. It answers when it finishes, which can take minutes.
app.deployRuns what the spec declaresBuilds a commit of the spec's branch at low priority, runs the release tasks, then switches to it when it answers its health path. It answers when it finishes, which can take minutes.
app.rollbackRuns what the spec declaresSwitches back to a release the machine kept, after checking its files still match the manifest the machine signed. Databases are not rolled back. It answers when it finishes, which can take minutes.
timer.runRuns what the spec declaresRuns one of the timers of the app's spec now, the way its schedule would.

Making or changing a spec carries the spec text itself next to the request. The request holds the spec's SHA-256 and the node refuses a spec whose digest is not the signed one. A deploy names the digest of the spec it was asked against, and a node whose spec is different refuses it. There is no verb that runs a command somebody types.

What a stolen console can and cannot do

Someone withCanCannot
A console session or API keyRead apps, specs, releases and masked logs.Deploy, roll back, change a spec or run a timer: every one needs a signature from your operator key. Deploy a commit that is not on the branch the signed spec names. Read a secret.
The console itselfHold back requests, or show a page that is not true. Send a request someone signed once, within its 15 minutes.Sign anything, change a spec, replay a request (the node remembers ids), or fake the node's signature on a release or an answer.
Your operator keyDeploy, roll back and change the specs of the apps root allowed on the servers that pinned the key.Anything on a server that did not pin it, or for an app root did not name.

Two places run code from your repository, and they are the same two the repository already controls: the build and release tasks, and the app and its timers. They run as the app's own users, inside the limits above, only for a commit on the branch your signed spec names.

The CLI is a thin client of the API at https://api.cloudverg.com/v1/ship/apps (list and read apps with their releases) and /v1/ops/requests (send a signed request, with the spec beside it when the verb carries one). POST /v1/ship/spec/check reads a verg.toml and returns the spec text and its SHA-256 without storing anything.