code-runner
Self-Hosting

Configuration

Every environment variable, grouped and explained.

code-runner is configured entirely by environment variables — there are no config endpoints. Copy .env.example to .env and adjust. Every default is safe for local development; the ones you must change before production are flagged.

Core / auth

VariableDefaultDescription
EXECUTOR_API_TOKENdev-insecure-token-change-meBearer token for the API. Change in prodopenssl rand -hex 32.
REDIS_URLredis://redis:6379Redis connection. Native TCP only for the worker (see below).
API_PORT8080API listen port.
MAX_QUEUE_DEPTH256POST /v1/execute returns 429 when LLEN(jobs:queue) >= this.

soketi

VariableDefaultDescription
SOKETI_HOSTsoketisoketi hostname.
SOKETI_PORT6001soketi port.
SOKETI_USE_TLSfalsetrue to connect over TLS.
SOKETI_APP_IDcode-runnerPusher app ID.
SOKETI_APP_KEYcode-runner-keyPusher app key — public, given to browser clients.
SOKETI_APP_SECRETcode-runner-secretPusher app secret. Never returned by any endpoint, never written to Redis. Change in prod.

Worker

VariableDefaultDescription
WORKER_MAX_SANDBOXES8Max concurrent live sandboxes per worker node.
DOCKER_HOSTunix:///var/run/docker.sockDocker endpoint. No Docker-in-Docker.
SANDBOX_RUNTIME(unset = runc)Set to runsc to run sandboxes under gVisor.
WORKER_WARMUP_MS30000Slot reclaim timeout: if /start never arrives after /execute, the slot is freed.
WORKER_HEARTBEAT_INTERVAL_MS5000How often the worker writes its heartbeat key.
WORKER_HEARTBEAT_TTL_MS20000TTL on the heartbeat key. Must be several times the interval.

Object storage / artifacts

All optional. With no bucket configured, file-artifact capture is disabled (pullable stdout/stderr still works). See Artifacts.

VariableDefaultDescription
AWS_ENDPOINT_URL_S3http://minio:9000 (dev)S3 endpoint (MinIO dev, Tigris/S3/R2 prod).
ARTIFACT_S3_PUBLIC_ENDPOINT(unset)Endpoint used to sign presigned GET URLs when clients fetch from a different host than the worker connects to (split-horizon). When set, the worker uploads via AWS_ENDPOINT_URL_S3 but signs against this. See Artifacts.
BUCKET_NAMEcode-runner-artifactsBucket name. Auto-created on worker boot.
AWS_ACCESS_KEY_IDminioadmin (dev)S3 access key.
AWS_SECRET_ACCESS_KEYminioadmin (dev)S3 secret key.
AWS_REGIONus-east-1Bucket region.
RUN_RESULT_TTL600Redis TTL on the RunResult (seconds).
PRESIGNED_URL_TTL86400Presigned artifact URL expiry (seconds, 24h).
ARTIFACT_S3_OBJECT_TTL3S3 lifecycle object expiry (days). Must be ≥ the presigned-URL TTL.

Each storage variable has an ARTIFACT_S3_* override (e.g. ARTIFACT_S3_BUCKET) if you'd rather not reuse the standard AWS_* names.

Stub (local demo only)

VariableDefaultDescription
API_BASE_URLhttp://api:8080API base URL as seen by the stub inside compose.
CHANNEL_AUTH_URLhttp://api:8080/v1/channel-authChannel-auth endpoint the stub uses.
ENABLE_CHANNEL_AUTHtrueRegister the optional POST /v1/channel-auth helper.

OpenTelemetry (off by default)

Telemetry emits nothing until OTEL_EXPORTER_OTLP_ENDPOINT is set. See Observability.

VariableDefaultDescription
OTEL_EXPORTER_OTLP_ENDPOINT(unset = off)The ON switch. Point at an OTLP collector.
OTEL_EXPORTER_OTLP_PROTOCOLhttp/protobufhttp/protobuf (:4318) or grpc (:4317).
OTEL_SERVICE_NAME_APIcode-runner-apiservice.name for the API.
OTEL_SERVICE_NAME_WORKERcode-runner-workerservice.name for the worker.
OTEL_RESOURCE_ATTRIBUTESservice.namespace=code-runnerResource attributes on every signal.
OTEL_TRACES_SAMPLERparentbased_traceidratioSampler; honors the caller's decision.
OTEL_TRACES_SAMPLER_ARG1.0Sampling ratio. Lower in prod (e.g. 0.05).
OTEL_SDK_DISABLED(unset)true hard-disables the SDK regardless of endpoint.

Redis

The worker requires native TCP Redis

The worker uses blocking BRPOP and SUBSCRIBE, which need a persistent TCP connection. Serverless REST-only Redis (e.g. Upstash's REST tier) cannot serve the worker — it has no way to hold a connection open for server-push. It is fine for the API (one-shot LPUSH/GET/SET).

Run a single native Redis/Valkey shared by both: self-hosted, Redis Cloud, ElastiCache/MemoryDB, or an Upstash dedicated (non-REST) cluster. The constraint is encoded as Config.RequiresNativeRedis() in the worker.

Production checklist

  • EXECUTOR_API_TOKEN — a real random token.
  • SOKETI_APP_SECRET (and ideally _APP_KEY/_APP_ID) — real secrets.
  • REDIS_URL — a native TCP Redis reachable by both API and worker.
  • OTEL_TRACES_SAMPLER_ARG — lowered (e.g. 0.05) if telemetry is on.
  • WORKER_MAX_SANDBOXES — tuned to the node's CPU/memory.
  • Consider SANDBOX_RUNTIME=runsc for an extra isolation layer.

On this page