Contents

Self-hosting and deployment

Run ServerGym locally in Node.js 24+ with zero container dependencies, or deploy the full three-surface stack with Compose, Nginx, and the Incus Linux container runner.

Three-surface architecture (compose.yaml)

Production deployment separates static public sites from the Node runtime while keeping every hostname behind one unprivileged Nginx edge container (site/nginx.conf on port 8080):

HostnameWhat serves it
servergym.comStatic files from site/public/ on web:8080; only POST /contact proxies to api:4000.
www.servergym.comPermanent 308 redirect to https://servergym.com.
docs.servergym.comPre-built static documentation from site/docs/public/ on web:8080.
app.servergym.comProxied by web:8080 to api:4000 (React SPA, REST API, Stripe billing/webhooks, and /ws/ terminal sockets).

Health probes are served at GET /healthz on web:8080 and GET /api/health on api:4000.

Local development vs. Coolify

Sandbox drivers

Select how lab environments execute using SANDBOX_DRIVER:

DriverHow it runs
localDefault for local development and CI. Runs an isolated temporary rootfs and pure-TypeScript POSIX shell inside Node with zero daemon dependencies.
incusProduction driver. Connects over HTTPS + Bearer auth (RUNNER_URL and RUNNER_AUTH_TOKEN) to a dedicated Linux Incus runner host (runner/) booting ephemeral Ubuntu, AlmaLinux 9, and Debian 12 system containers with live WebSocket PTY terminals.
dockerLaunches per-session containers via DOCKER_SOCKET (default /var/run/docker.sock) with NetworkMode=none, CapDrop=ALL, no-new-privileges, 512 MB RAM, 1 CPU, and a 128-PID limit.
vmExtension scaffold for integrating a custom Firecracker or Proxmox VM hypervisor.

Core environment variables

In production (NODE_ENV=production), ServerGym refuses to start unless AUTH_SECRET is set to a non-default secret of at least 16 characters (generate one with openssl rand -hex 32).

# Required in production
AUTH_SECRET=<random-32-byte-hex>
APP_URL=https://app.servergym.com
[email protected]
REQUIRE_AUTH_FOR_LABS=true
LABS_PUBLIC_ENABLED=true          # Defaults to false in compose.yaml until your runner is ready
ENABLE_DEMO_AUTH=false

# Sandbox driver: local | incus | docker | vm
SANDBOX_DRIVER=incus
RUNNER_URL=https://runner.internal.example
RUNNER_AUTH_TOKEN=<shared-runner-secret>

# Optional custom interview hostname (blank by default)
CUSTOM_HIRE_HOSTS=

# Resend mail delivery for /contact, welcome emails, and hiring notifications
RESEND_API_KEY=re_...
CONTACT_FROM=ServerGym <[email protected]>
[email protected]
MAIL_FROM=ServerGym <[email protected]>

# Optional Stripe billing (seed catalogue once via: pnpm billing:setup-stripe)
STRIPE_SECRET_KEY=rk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Optional LLM keys (falls back to deterministic simulation when unset)
GEMINI_API_KEY=
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
OPENROUTER_API_KEY=
LLM_PROVIDER=auto