Deploy
Run Cardinal in production on one VM with Docker Compose.
Production runs one release image. The same image serves the web and runs background jobs. CARDINAL_ROLE picks which.
CARDINAL_ROLE | Serves HTTP | Runs jobs |
|---|---|---|
web | Yes | No |
worker | No | Yes |
all (default) | Yes | Yes |
Every node inserts jobs. Nodes share nothing but Postgres and the S3 bucket, so you can add web or worker nodes behind a load balancer.
The shipped target is Docker Compose on one VM (deploy/docker-compose.prod.yml). It runs one web node, one worker node, Postgres 17, Gotenberg for PDFs and Caddy for TLS. systemd and Helm targets are planned but not available yet.
Steps
Point DNS for your domain at the VM. Open ports 80 and 443 only.
Create a private S3 bucket. Give the key s3:ListBucket on the bucket and s3:GetObject, s3:PutObject and s3:DeleteObject on its objects. The stack never creates the bucket.
On a machine with the toolchains, build the build context with ERP, then build the image on the VM's own CPU architecture:
scripts/workspace-ctx.sh /tmp/ctx git@github.com:revaik-org/erp-cardinal.git v0.1.0-alpha.1
# copy /tmp/ctx to the VM, then in it:
docker build -t cardinal-erp:latest .On the VM, put docker-compose.prod.yml, prod.Caddyfile and .env in one folder. Copy .env from prod.env.example, fill it and chmod 600 it.
Start the stack:
docker compose -f docker-compose.prod.yml up -dA one-shot migrate service runs before the nodes start.
Create the first site, claimed for its System Manager, with the ERP app. deploy/README.md has the exact docker compose run ... bin/cardinal eval command.
The .env file
| Variable | Value |
|---|---|
CARDINAL_DOMAIN | erp.example.com |
CARDINAL_TLS | Your ACME email, or internal for Caddy's own CA |
CARDINAL_IMAGE | cardinal-erp:latest |
POSTGRES_PASSWORD | openssl rand -hex 24 |
CARDINAL_MASTER_KEY | openssl rand -base64 32. Never change it after the first start |
CARDINAL_S3_ENDPOINT, _REGION, _BUCKET, _ACCESS_KEY, _SECRET_KEY | Your bucket |
CARDINAL_ADMIN_PASSWORD | The first System Manager's password |
Other settings
Every other variable, such as CARDINAL_SITE_URL, CARDINAL_TRUSTED_PROXIES and POOL_SIZE, is in Configuration.
Updating
Build the new image, then run docker compose -f docker-compose.prod.yml up -d again. migrate runs before the nodes restart.
For one-off commands use docker compose run --rm web bin/cardinal eval '...'. The nodes run with Erlang distribution off, so there is no remote shell.
The stack is a single failure domain. See Backups. To build the image yourself, see Releases.