Provision

Prepare a server to host Vela apps. Any Debian-based host reachable over SSH can be used. Run this once per server, before the first deploy.

Syntax

$ vela provision <target>
$ vela provision root@example.com

The target is an SSH destination: an alias from ~/.ssh/config, or user@host. Provisioning is idempotent — running it again on a prepared server brings it up to date rather than starting over.

Options

  • -i, --identity <file> - SSH private key to authenticate with
  • --ssh-port <port> - SSH port
  • --accept-host-keys - Trust an unknown host key on first connect (CI)
  • --pb-version <version> - PocketBase version to install, defaults to the one this CLI develops against
  • --node-major <version> - Node.js major version to bring the server up to, defaults to 26. A server already on a later major keeps it
  • --no-swap - Do not add a swapfile. One is added when the server has under 2 GB of memory and no swap

Stack

Vela installs the following on the server:

  • Node.js
  • Caddy, with automatic HTTPS
  • PocketBase
  • systemd units for the app and the database
  • A swapfile, on a server with under 2 GB of memory and no swap

A system user vela is created to own and run the apps. Caddy gets an import /etc/vela/caddy/*.caddy line appended to its existing Caddyfile — an existing configuration is otherwise left alone, and the result is validated before Caddy is reloaded.

Swap

A server with under 2 GB of memory and no swap has no slack: one dependency install beside the running apps is enough for the kernel to start killing processes, and it does not pick only the newcomer. On such a server provisioning creates /swapfile, 2 GB, or 1 GB when under 8 GB of disk is free, turns it on and adds it to /etc/fstab so it survives a reboot.

Swap that is already there, of any size and kind, is left alone. With under 4 GB of disk free the swapfile is skipped and the reason is printed. Inside a container, or wherever the kernel refuses a swapfile, nothing is done. None of this can fail a provision, and the summary at the end shows the server’s memory and swap. Pass --no-swap to leave the server as it is.

Upgrading Node

Running vela provision again with a later --node-major moves the server to it. Dependencies the apps installed were compiled for the old major, so those apps need a redeploy, and the command names them: each instance with dependencies installed, by app, target and URL. An app with no runtime dependencies has nothing compiled for the old Node and is left off the list. Nothing is redeployed automatically; run vela deploy in each app’s own project, with -t <target> for any target but production.

Layout

Apps live under /var/lib/vela, with configuration in /etc/vela:

/var/lib/vela/apps/<app>       releases and data, per app
/var/lib/vela/state            server-wide state: port assignments, one lock per target
/var/lib/vela/script-versions  the server scripts, one directory per CLI version
/var/lib/vela/trash            data removed by a purge, kept for two weeks
/etc/vela/apps                 environment files, readable only by root
/etc/vela/caddy                generated Caddy snippets, one per app

Each deployed target runs two systemd services, vela-web@ for the Node server and vela-pb@ for the database, on an internally assigned port. Several apps and several targets of the same app can share one server.

Requirements

For HTTPS to be provisioned automatically on deploy, the server must have a public IP address and the domain must point at it. This is what lets Caddy obtain certificates. Provisioning needs root, either directly or through sudo.