Configuration
Environment variables, node roles, ports and the workspace file.
A node reads all runtime settings from environment variables in platform/config/runtime.exs. Nothing comes from files on the node. In a dev workspace, cardinal start and the other commands build these variables from cardinal.workspace.exs.
Node role
CARDINAL_ROLE | Serves HTTP and realtime | Executes jobs |
|---|---|---|
web | Yes | No |
worker | No | Yes |
all (default) | Yes | Yes |
Every node inserts jobs, whatever its role. A bad value stops the node at boot. cardinal start in dev serves and executes jobs.
Environment variables
| Variable | Default | Use |
|---|---|---|
DATABASE_URL | Postgres connection | |
POOL_SIZE | 10 | Database connections per node |
PORT | 4000 | HTTP port |
CARDINAL_ROLE | all | See above |
CARDINAL_MASTER_KEY | Seals every site's data key. Generate with openssl rand -base64 32. Never change it after the first start | |
CARDINAL_S3_ENDPOINT, CARDINAL_S3_REGION, CARDINAL_S3_BUCKET, CARDINAL_S3_ACCESS_KEY, CARDINAL_S3_SECRET_KEY | dev RustFS outside prod | The object store for files |
CARDINAL_S3_PUBLIC_ENDPOINT | the S3 endpoint | Where browsers reach the store, for presigned download URLs |
CARDINAL_PDF_URL | http://localhost:3000 | The Gotenberg sidecar that renders PDFs |
CARDINAL_SITE_URL | https://{host} in a release, http://{host}:$PORT otherwise | Origin of links in mail. {host} is the site's host |
CARDINAL_TRUSTED_PROXIES | none | CIDRs whose X-Forwarded-* headers the node trusts |
CARDINAL_OUTBOUND_ALLOW | none | CIDRs, addresses or host names that are not public but that Email Accounts and Webhooks may reach |
CARDINAL_SANDBOX_LIMIT | 16 | Template sandboxes a node runs at once, 64 MB each |
CARDINAL_JOB_RESCUE_AFTER | 2100 (35 minutes) | Seconds before a job a dead node left executing runs again |
CARDINAL_DESK_DIR, CARDINAL_WEB_DIR, CARDINAL_DESK_APPS_DIR | Built desk, website and app desk bundles. The image sets them | |
CARDINAL_TELEGRAM_API | https://api.telegram.org | Telegram Bot API host |
CARDINAL_GOOGLE_MAPS_API | https://maps.googleapis.com | Google Maps host for Directions calls |
CARDINAL_DEV_BUILD | unset | Set to 1 at image build time to add the gate test app and the x-cardinal-node header. Never in production |
CLI-only variables
| Variable | Read by |
|---|---|
CARDINAL_DB_PASSWORD | cardinal init --db external |
CARDINAL_ADMIN_PASSWORD | new-site --admin-email, setup complete, setup reopen |
CARDINAL_HOME | bin/cardinal: the framework checkout |
PERCH_PORT | cardinal perch (4100 when unset) |
Ports
The repo's dev stack (deploy/docker-compose.yml) and a Docker workspace use these services:
| Service | Port | Use |
|---|---|---|
| Postgres 17 | 5432 | Database |
| RustFS | 9000, 9001 | S3 API and console |
| Mailpit | 1025, 8025 | SMTP and web inbox |
| Gotenberg | 3000 | PDF rendering |
| Cardinal | 4000 | HTTP |
| Perch | 4100 | Workspace watcher |
cardinal init picks the first free port at or above each default when it creates a Docker workspace, so two workspaces can run side by side. The ports it chose are in cardinal.workspace.exs.
The workspace file
[
apps: [erp: [git: "git@github.com:revaik-org/erp-cardinal.git", commit: "6a96e90f..."]],
name: "acme",
pkg: "bun",
db: "docker",
db_port: 5433,
s3_port: 9002,
mail_port: 1026,
mail_ui_port: 8026,
pdf_port: 3001,
web_port: 4001,
outbound_allow: "127.0.0.1/32,::1/128"
]An external-database workspace has db: "external", db_host, db_port, db_user and db_name (cardinal_<name>) instead of the service ports.
| Workspace path | Holds |
|---|---|
cardinal.workspace.exs | Apps, pins and ports |
.cardinal/secrets.exs | The dev master key. Keep it |
apps/ | App sources |
mix.exs, config/ | Build the platform, core and the listed apps |
build/ | Built desk plugins and build.json |
tools/perch/ | Perch, after cardinal perch get |