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 Ubuntu 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.
Terminalelements 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, an incremental deploy completes 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 Ubuntu box with SSH access, at any provider. A $5/month VPS runs a complete deployment.
One machine is a complete deployment. Elements installs and manages the same
bundled Postgres that development uses, so a single Ubuntu box runs the app, the
load balancer, and the database. To run on several machines, point them all at
one shared Postgres cluster (set DB_HOST), and every feature works across all
of them with no other change: live tables, channels, sessions, jobs, and stored
files. A write on any app server reaches watching browsers on every app server,
because broadcasts travel through the shared database. Uploaded files go in
Postgres, where every machine reads them, or in S3 or any object store. 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.
Each deploy machine is dedicated to one app, at /elements/app whatever your
project folder is called, so renaming the folder deploys to the same place.
Each app gets its own machines, and deploying a different project to a machine
replaces the app there.