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):
| Hostname | What serves it |
|---|---|
servergym.com | Static files from site/public/ on web:8080; only POST /contact proxies to api:4000. |
www.servergym.com | Permanent 308 redirect to https://servergym.com. |
docs.servergym.com | Pre-built static documentation from site/docs/public/ on web:8080. |
app.servergym.com | Proxied 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
- Pure Node development — run
pnpm devwithSANDBOX_DRIVER=localand Node.js 24+. The API server routessite.localhost,docs.localhost, andapp.localhost/localhostdirectly byHostheader without Docker. - Local Compose —
compose.override.yamlautomatically binds127.0.0.1:8080:8080(Nginx edge) and127.0.0.1:4000:4000(direct API) for local testing. - Coolify production —
compose.yamlpublishes no host ports; Coolify’s TLS reverse proxy terminates HTTPS and forwards directly toweb:8080over the internal container network.
Sandbox drivers
Select how lab environments execute using SANDBOX_DRIVER:
| Driver | How it runs |
|---|---|
local | Default for local development and CI. Runs an isolated temporary rootfs and pure-TypeScript POSIX shell inside Node with zero daemon dependencies. |
incus | Production 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. |
docker | Launches 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. |
vm | Extension 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