cardinal

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_ROLEServes HTTP and realtimeExecutes jobs
webYesNo
workerNoYes
all (default)YesYes

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

VariableDefaultUse
DATABASE_URLPostgres connection
POOL_SIZE10Database connections per node
PORT4000HTTP port
CARDINAL_ROLEallSee above
CARDINAL_MASTER_KEYSeals 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_KEYdev RustFS outside prodThe object store for files
CARDINAL_S3_PUBLIC_ENDPOINTthe S3 endpointWhere browsers reach the store, for presigned download URLs
CARDINAL_PDF_URLhttp://localhost:3000The Gotenberg sidecar that renders PDFs
CARDINAL_SITE_URLhttps://{host} in a release, http://{host}:$PORT otherwiseOrigin of links in mail. {host} is the site's host
CARDINAL_TRUSTED_PROXIESnoneCIDRs whose X-Forwarded-* headers the node trusts
CARDINAL_OUTBOUND_ALLOWnoneCIDRs, addresses or host names that are not public but that Email Accounts and Webhooks may reach
CARDINAL_SANDBOX_LIMIT16Template sandboxes a node runs at once, 64 MB each
CARDINAL_JOB_RESCUE_AFTER2100 (35 minutes)Seconds before a job a dead node left executing runs again
CARDINAL_DESK_DIR, CARDINAL_WEB_DIR, CARDINAL_DESK_APPS_DIRBuilt desk, website and app desk bundles. The image sets them
CARDINAL_TELEGRAM_APIhttps://api.telegram.orgTelegram Bot API host
CARDINAL_GOOGLE_MAPS_APIhttps://maps.googleapis.comGoogle Maps host for Directions calls
CARDINAL_DEV_BUILDunsetSet to 1 at image build time to add the gate test app and the x-cardinal-node header. Never in production

CLI-only variables

VariableRead by
CARDINAL_DB_PASSWORDcardinal init --db external
CARDINAL_ADMIN_PASSWORDnew-site --admin-email, setup complete, setup reopen
CARDINAL_HOMEbin/cardinal: the framework checkout
PERCH_PORTcardinal perch (4100 when unset)

Ports

The repo's dev stack (deploy/docker-compose.yml) and a Docker workspace use these services:

ServicePortUse
Postgres 175432Database
RustFS9000, 9001S3 API and console
Mailpit1025, 8025SMTP and web inbox
Gotenberg3000PDF rendering
Cardinal4000HTTP
Perch4100Workspace 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

cardinal.workspace.exs
[
  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 pathHolds
cardinal.workspace.exsApps, pins and ports
.cardinal/secrets.exsThe 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

On this page