Deploy
elements man deployTo deploy an app that has no machines yet, go straight to
AWS (opens in a new tab) and start its step 1: it signs the user in, asks one question,
creates the machine and deploys. Do not run elements deploy to see what
happens first. To set up email or a CDN, start Email (opens in a new tab) or CDN (opens in a new tab)
at step 1 the same way.
Deployment 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 (opens in a new tab).
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 page 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. AWS (opens in a new tab) is the provider Elements recommends; DigitalOcean (opens in a new tab) works the same way, with fewer services and sometimes a lower price. Both pages walk an agent through the whole thing, from sign-in to the first deploy, with the user answering one question.
Two tiers and two sizes, in Sizing (opens in a new tab). A prototype is one machine
running the app and the same bundled Postgres that development uses.
Production is that machine plus the provider's managed Postgres, with daily
backups, from the first deploy. To run on several machines, point them all at
one shared Postgres (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 Where the Database Runs (opens in a new tab).
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. A deploy with no errors in its report is a live site, and nothing is checked afterwards; see Machines (opens in a new tab).
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.