Deploy
elements man deploy Read as markdownDeployment is a core part of Elements, not a separate toolchain bolted on top.
Run elements deploy and Elements ships your app to any Linux box over SSH.
The two project servers speak to each other directly, so only changed files
transfer and rebuild: a first deploy to a new machine takes a few seconds, and
a deploy after that lands in a few hundred milliseconds.
elements deploy # production
elements deploy staging # named environment
elements deploy -json # one shot, structured, exit 1 on error
The loop is one command: run elements deploy -json, read its diagnostics,
report them. That output covers the local build and every machine, so a failed
deploy needs no second source and nobody has to log in to a box to find out what
happened. See What Deploy Does.
Once the machine has been provisioned, incremental deploys often complete in under a second, because only the files that changed are transferred and rebuilt on the deployment machine. Migrations apply to the test database first and then the app database, and the new release goes live with an atomic directory swap that keeps the previous release serving traffic until the new one is ready. The deploy either succeeds entirely or fails entirely, and a failed deploy leaves the previous release running.
Elements ships with a built-in load balancer, so automatic SSL via Let's Encrypt, request balancing across machines, and a maintenance fallback are part of Elements rather than separate services you have to provision and configure yourself. You can target any Linux box with SSH access. A $5/month VPS works fine, and you are not locked in to a specific provider.
The deployment machine runs the same bundled Postgres that development uses:
Elements installs and manages a per-machine Postgres cluster on the box, so a
single Linux box is a complete deployment: app, load balancer, and database.
Pointing at a remote or hosted database instead is an opt-in escape hatch (set
DB_HOST); see Database on the Deploy
Machine.
To deploy, you give Elements the public and private IP addresses of each machine and the SSH credentials. Elements handles everything else: provisioning the OS, creating the system user, installing systemd units, bringing up the Postgres cluster, starting the load balancer, issuing SSL certificates, running migrations, and swapping releases.