Space Works Machines · Install and run
Configuration reference
Every environment variable the app, its background roles, its images and the deployment scripts read.
For local development, docker compose up -d starts PostgreSQL, persistent Redis, Silo with a private bucket
and scoped application identity, and Mailpit. .env.example targets these loopback services. Mailpit captures
email at http://127.0.0.1:8025; Silo's console is http://127.0.0.1:9001. These public development credentials
are never suitable for a server. Build jobs with npm run build:jobs, run npm run worker and run beat in
another terminal with JOBS_HEALTH_PORT=3461 npm run beat (PowerShell: $env:JOBS_HEALTH_PORT='3461'; npm run beat).
Alternatively npm run dev:local loads .env, starts the local services, applies migrations and supervises
the web, worker and beat in one terminal; Ctrl+C or a child failure stops the app processes together.
For already-provisioned local services, npm run dev:stack generates Prisma/builds jobs and starts the same
supervisor. Both refuse remote database, migration, Redis, S3 and SMTP targets. Local health ports default
to 3460/3461; SWM_DEV_WORKER_PORT and SWM_DEV_BEAT_PORT override them. Web uses PORT (3000 by default).
SPACEWORKS_LOCAL_STACK=1 is injected into supervised children for loopback health and graceful IPC shutdown;
it is an internal local-tool flag, not a production deployment setting.
Production uses the installer's generated secrets and TLS stack, including separate worker and beat containers.
The backend and separate frontend share a Next build limit of two page-data workers. Container CPU
quotas can leave the larger host CPU count visible; this bound prevents a build from spawning dozens
of static-generation workers on a small memory allocation.
Templates: .env.example (development) and
.env.production.example (the bundled install's .env and the cloud
cloud.env). The installer generates every secret for you.
In production the app, worker and beat validate their settings at start (lib/env.ts) and refuse to run with
a missing secret, a plain-text database or Redis connection, or mismatched public origins.
Application
| Variable | Required | Description |
|---|---|---|
NODE_ENV |
production | production turns on the start-up validation, secure cookies and HSTS. |
DATABASE_URL |
yes | Runtime PostgreSQL URL. Production needs sslmode=require, verify-ca or verify-full; a transaction pooler on :6543 needs pgbouncer=true. The bundled stack uses the least-privilege role swmach_app. |
DIRECT_URL |
no | Direct or session connection for prisma migrate (a role that owns the schema). Defaults to DATABASE_URL. Same TLS rule. |
REDIS_URL |
production | Rate limits, address blocks and the BullMQ queues. Production requires rediss://. |
AUTH_SECRET |
yes | Auth.js secret, 32+ characters. |
AUTH_URL |
production | The public origin. Must equal NEXT_PUBLIC_BASE_URL. |
NEXT_PUBLIC_BASE_URL |
production | The canonical origin for links in email (sign-in links, invites, notices). Release images get it at start (placeholder replacement); your own builds compile it in. |
ALLOW_PLAIN_HTTP |
no | 1 allows an http:// origin, for a LAN or trial install on plain HTTP. Never on the internet. |
NEXT_PUBLIC_HOSTED_BY |
no | Footer credit "Hosted by …". |
ALLOWED_ACTION_ORIGINS |
no | Extra hostnames allowed to call Server Actions (a CDN in front). Build time only; release images refuse it. |
TRUSTED_PROXY_IP_HEADER |
production | The client-IP header your edge overwrites: x-real-ip (bundled Caddy), cf-connecting-ip (Cloudflare) or x-forwarded-for. |
TRUSTED_PROXY_HOPS |
no | With x-forwarded-for, how many trusted proxies append to it (default 1). |
CRON_SECRET |
production | Bearer secret for POST /api/internal/jobs and POST /api/internal/outbox, the fallback for hosts without a beat process. |
OUTBOX_RETENTION_DAYS |
no | Days to keep delivered outbox rows (30). |
HEALTHCHECK_SECRET |
production | Bearer secret for GET /api/health/db. /api/health is open liveness. |
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY |
production | Base64 of a 16, 24 or 32-byte key, stable across every container. Release images refuse to start without it. |
MFA_ENCRYPTION_KEY |
production | Base64 of 32 bytes; encrypts authenticator seeds and the SMTP password saved in Super admin → Settings. Never change it once in use. |
PAYMENT_SECRETS_KEY |
production | Base64 of 32 bytes; AES-GCM key for each space's Razorpay and Stripe secrets, its own SMTP password and its chat destinations. Generated by the installer; back it up. |
SUPER_ADMIN_EMAIL |
yes | The first super admin. The installer creates it with the password you give; super admins are created, revoked and given passwords only on the server with bash scripts/admin.sh. |
PWNED_PASSWORDS_CHECK |
no | 1 (default) refuses new passwords found in known data breaches, using Have I Been Pwned with k-anonymity (only a 5-character SHA-1 prefix leaves the server). 0 turns it off, for installs without internet access. |
EMAIL_FROM |
yes | Sender, Name <address@verified-domain>. Super admin → Settings overrides the email settings. |
SMTP_HOST, SMTP_PORT, SMTP_SECURE |
yes | Relay host, port (587, or 465 with SMTP_SECURE=true). |
SMTP_USER, SMTP_PASSWORD |
yes | Relay login. |
SMTP_SERVICE |
no | A Nodemailer well-known service instead of a host. |
SMTP_ALLOW_UNAUTHENTICATED |
no | 1 only for a private relay without authentication. |
S3_BUCKET, S3_REGION |
production | The private bucket. |
S3_ENDPOINT |
no | S3-compatible endpoint; HTTPS in production. |
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY |
no | Both or neither (an IAM role). |
S3_FORCE_PATH_STYLE |
no | 1 for Silo, MinIO and R2. |
BACKUP_PROVIDER, BACKUP_LAST_SUCCESS_AT, BACKUP_RETENTION_DAYS |
no | Backup posture shown in Super admin → Operations. BACKUP_RETENTION_DAYS also sets how long scheduled dumps stay (14 in the bundled stack). |
MIGRATE_ON_START |
no | 1 makes the backend role apply migrations before starting (Render). |
PORT, HOSTNAME |
no | Listening port and address inside the container (3000, 0.0.0.0). |
NODE_EXTRA_CA_CERTS |
no | Extra CA for Node; the bundled stack points it at its private CA. |
NEXT_DEV_ALLOWED_ORIGINS |
no | Development only: extra hosts allowed to load dev assets. |
There are no OAuth or SSO settings: the AUTH_GOOGLE_*, AUTH_GITHUB_* and AUTH_APPLE_* variables of the
platform this was forked from are not read, and neither is SCHEDULER_MODE.
Background jobs (worker and beat)
| Variable | Default | Description |
|---|---|---|
JOBS_QUEUE_PREFIX |
swm:jobs |
Prefix for the BullMQ keys in Redis. Lowercase letters, digits, :, _ and -, up to 40 characters. Give two installations sharing one Redis different prefixes. |
JOBS_HEALTH_PORT |
3460 |
Port of the worker's and beat's GET /health. |
QUEUE_OUTBOX_CONCURRENCY, QUEUE_SCHEDULED_CONCURRENCY, QUEUE_SYNC_CONCURRENCY |
5, 2, 2 | Jobs one worker runs at once per queue, 1 to 64. |
JOBS_INPROCESS |
false |
Development only, and only without REDIS_URL: true delivers the outbox and purges old data from a one-minute timer in the web process. Ignored in production. |
Split hosting (website on Netlify)
| Variable | Where | Description |
|---|---|---|
DEPLOYMENT_MODE |
backend | backend serves only the API and Server Actions; monolith (default) serves everything. |
FRONTEND_GATEWAY_SECRET |
both | 64 hex characters shared by the website and the backend. |
BACKEND_ORIGIN, NEXT_PUBLIC_BACKEND_ORIGIN |
website | The backend's HTTPS origin. The frontend image gets it at start. |
FRONTEND_TRUSTED_IP_HEADER |
website | x-nf-client-connection-ip on Netlify, x-real-ip behind your own proxy. |
Tests and demo data
CI with ALLOW_INSECURE_PRODUCTION_TESTS=1 relaxes the TLS checks in CI only. TEST_DATABASE_URL points the
integration tests at a disposable database. DEMO_PASSWORD and DEMO_MFA_SECRET feed npm run db:seed-demo.
Deployment (bundled .env and cloud.env)
| Variable | Default | Description |
|---|---|---|
SWM_REPOSITORY |
SpaceWorks-Labs/SpaceWorks-Machines |
Repository the installer, updater and runner follow (a fork works). |
SWM_BACKEND_IMAGE, SWM_FRONTEND_IMAGE |
ghcr.io/<owner>/spaceworks-machines-backend / -frontend |
Image names, derived from the repository owner. |
SWM_IMAGE_TAG |
.spaceworks-version, else latest |
The release the stack runs. |
SWM_LAYER |
none |
none plain HTTP through Caddy, tls automatic HTTPS, proxy your own proxy on 127.0.0.1:8080. |
SWM_STORAGE |
bundled |
external drops Silo for the S3_* bucket. |
PUBLIC_APP_BASE_URL |
The public origin; becomes AUTH_URL and NEXT_PUBLIC_BASE_URL. |
|
SITE_ADDRESS |
Caddy's site: <domain> for automatic HTTPS, http://<host> for plain HTTP. |
|
TLS_EMAIL |
Let's Encrypt account email (SWM_LAYER=tls). |
|
HTTP_PORT, HTTP_PORT_BIND, TLS_HTTPS_PORT |
80, 0.0.0.0, 443 |
Caddy's published ports. |
API_BIND, API_PORT |
127.0.0.1, 8080 |
Where the app listens for your proxy (SWM_LAYER=proxy). |
APP_BIND, APP_PORT |
127.0.0.1, 8080 |
Where the cloud stack's app listens. |
POSTGRES_PASSWORD |
generated | Owner role swmach (migrations, backups). |
POSTGRES_APP_PASSWORD |
generated | Runtime role swmach_app (data only). |
REDIS_PASSWORD |
generated | Redis requirepass. |
MINIO_ROOT_USER, MINIO_ROOT_PASSWORD |
generated | Silo administrator. |
S3_APP_PASSWORD |
generated | Secret of the swmach-app storage identity, limited to the bucket. |
BACKUP_INTERVAL_HOURS |
24 |
Scheduled database dump and bucket mirror interval. |
SILO_IMAGE_TAG |
pinned | Silo release. |
The Compose stacks set JOBS_HEALTH_PORT=3460 on the worker and beat themselves; JOBS_QUEUE_PREFIX can be
set in the settings file.
Scripts and images
| Variable | Used by | Description |
|---|---|---|
SWM_DIR |
install.sh, deploy job |
Install directory (/opt/spaceworks-machines). |
SWM_INSTALL_REPOSITORY_PINNED |
installer | Set when the repository was chosen before download. |
SWM_STATIC_ENV_FILE |
wrapper | Settings file (<install>/.env bundled, /etc/spaceworks-machines/cloud.env cloud). |
SWM_UPDATE_INSTALL_DIR |
wrapper, updater | The install a staged updater works on. |
SWM_COMPOSE_BUILD_LAYER |
wrapper, setup.sh --build |
1 builds the backend image from the checkout. |
SWM_BUILD_KEY |
wrapper | Throwaway Server Actions key for local builds (generated per run). |
SWM_COMPOSE_PROJECT |
wrapper | Compose project (swmach, swmach-cloud, swmach-smoke). |
SWM_TLS_DIR, SWM_BACKUP_DIR |
compose | Certificate and backup directories (./tls, ./backups). |
SWM_RUNNER_DIR |
install-runner.sh |
Runner directory (/opt/spaceworks-machines-runner). |
SWM_DEPLOY |
GitHub repository variable | true enables the release workflow's deploy job. |
SWM_TOPOLOGY |
ops role | bundled or cloud; the runtime-role check runs only for bundled. |
SWM_NEXT_DIR |
entrypoint | Where the web build is (/app/.next, frontend /app/frontend/.next). |
SWM_DISABLE_BUILD_CACHE, SWM_FRONTEND_STANDALONE |
Dockerfile | Image build switches. |
SWM_SMOKE_PORT |
compose-smoke.sh |
The smoke test's edge port (18080). |
Disposable installer and recovery acceptance
On an isolated Linux CI runner with Docker, Buildx, Compose, OpenSSL and age, run
CI=true SWM_IMAGE_TAG=acceptance bash scripts/test-vps-install.sh. It uses the confirmed setup
writer and setup.sh --build, builds both images, checks Docker secret exclusions and invokes
scripts/test-vps-recovery.sh. The latter accepts only a swmach-recovery-* project carrying the
.spaceworks-recovery-test marker. It encrypts a real SQL/object/configuration backup with age,
copies the encrypted archive off the installation, destroys the source volumes, and restores into
a different empty project/configuration directory. It verifies relational data, a private object,
the actual application MFA cipher and worker/beat health. Before and after restoration, a local Mailpit
capture using the recovered CA proves verification, reset and magic-link messages travel through SQL,
Redis and the real worker over authenticated STARTTLS, with bearer payload deletion and no resend.
SWM_RECOVERY_SMOKE=1 enables only the
operator fixture probe; it is never needed in a deployed application. The optional
SWM_TEST_HTTP_PORT selects the fixture's loopback HTTP port (default 18081).
This source test does not verify public release downloads, a host Docker/systemd installation, public DNS/ACME or external SMTP deliverability. Host backups still document operator-managed off-server encryption; the acceptance recipe exercises that exact boundary.
From SpaceWorks-Machines/docs/CONFIGURATION.md at b60fee1, updated 2026-10-29. Suggest a change