Skip to content
Documentation

Deployment

This page is published from the server repository. Edit on GitHub View source

How the server is packaged and run: the Docker image stages, the development Compose stack, the nginx proxy, certificates, and the state that has to persist. README-SETUP.md walks through starting the stack and signing in; this page is the reference behind it.

The supplied stack is a development and lab deployment. Nothing here is a supported production configuration yet.

Docker image

Dockerfile builds from node:20-alpine (Node 20 is also what CI tests on) in five stages:

StageContentsUsed by
baseNode 20 on Alpine plus OpenSSL, which Prisma's query engine links againstEvery stage
depsnpm cidev, builder
devThe source tree, a generated Prisma client, npm run dev on port 3000docker-compose.yml
builderprisma generate and next build with output: 'standalone'runner
runnerThe standalone server and static assets only, run as the unprivileged nextjs user (uid 1001) with NODE_ENV=production and NEXT_MANUAL_SIG_HANDLE=trueProduction-style runs

The standalone output is served by node server.js, not by next start. scripts/start-standalone.mjs (npm start) does the same outside Docker after npm run build: it copies the static assets and public/ next to the standalone server, as the image does, then starts it.

The runner image does not apply the schema. Run npx prisma db push against its database from a build environment first (Data model).

The Compose stack

docker-compose.yml runs three services:

ServiceImageRolePublished on the host
postgrespostgres:15-alpineDatabase, with a pg_isready health check and a named volume postgres_data5432
serverdev stage of the DockerfilePushes the schema (prisma db push --skip-generate), then runs next dev. Starts once postgres is healthy.Nothing; port 3000 inside the network
proxynginx:alpineTerminates TLS and mTLS on 84438443

The server service bind-mounts the repository at /app (with anonymous volumes over node_modules and .next), so code changes reload without a rebuild. A schema change needs a rebuild (docker compose build server) so the generated Prisma client in the image matches. The mounts carry :z so they are readable under SELinux.

The application port is deliberately not published: everything should reach the application through the proxy. To use the console from the same machine, publish it on loopback only with an override file (README-SETUP.md).

docker-compose.test.yml is separate: one PostgreSQL on port 5433 for the test suites (Testing).

The proxy

nginx.conf is mounted as a template; the nginx image substitutes ${NGINX_PROXY_SECRET} into it at start, and only NGINX_* variables, so nginx's own $variables are untouched.

On every request the proxy sets, overwriting any value the client sent:

HeaderValue
X-Client-Cert-Verified$ssl_client_verify: SUCCESS, NONE or a failure reason
X-Client-Cert-Subject$ssl_client_s_dn, the client certificate's subject
X-Proxy-SecretNGINX_PROXY_SECRET
X-Real-IPThe connection's address
X-Forwarded-For, X-Forwarded-Proto, HostThe usual forwarding values

Client certificates are requested but optional at the TLS layer (ssl_verify_client optional), because browsers and the scheduler use the same port. Locations then decide:

LocationClient certificateOther limits
/api/ingest/, /api/v1/ingest/Required (401 otherwise)Body up to 8 MiB
/api/release/{manifest,artifact,key-rotation}, /api/content/manifest/<ring>, /api/content/artifact, /api/snapshot/{manifest,artifact}Required
/api/content/ioc-feedNot used (session-authenticated)Body up to 32 MiB, matching the route's own limit
/api/cron/Not used (bearer-authenticated)10 requests/s per address, burst 20, 429 past it
Everything elseNot usednginx default 1 MiB body

Several application instances can sit behind one proxy by adding them to the upstream server block; the application keeps its state in PostgreSQL, the archive and the artifact store, which must then be shared.

Certificates

scripts/generate-dev-certs.sh writes a throwaway PKI to certs/, which the proxy mounts read-only:

FilePurpose
ca.crt, ca.keyDevelopment CA. nginx trusts it for client certificates; agents trust it for the server.
server.crt, server.keyProxy certificate, with localhost, 127.0.0.1 and ::1 as subject alternative names, plus any in DEV_CERT_SANS
agent-test.crt, agent-test.keyTest agent certificate, CN=agent-test-001

The agent's TLS stack is strict: it needs X.509 v3 certificates, a CA with basicConstraints=CA:TRUE, and the server's name in subjectAltName (a CN alone is refused). The script produces exactly that, and your own PKI must too. Agent certificates need extendedKeyUsage=clientAuth; their CN is the enrollment ID (Agent protocol). The agent trusts only public roots unless given a CA (--ca-cert, or server.ca_cert in agent.toml).

Persistent state

StateWhereNotes
Databasepostgres_data volumeEverything except what follows.
Artifact storestorage/ under the application's working directoryContent artifacts, signed manifests, release files and key rotations (Content and releases). In the Compose stack this is storage/ in the repository checkout, through the bind mount. The runner image has no volume for it: mount one at /app/storage, writable by uid 1001.
Telemetry archiveLAKE_DIR or the LAKE_S3_* bucketOptional. The Compose stack includes no object store.
Certificatescerts/Mounted into the proxy.

Network

Outbound connections the application may make, each only when configured:

  • PostgreSQL (DATABASE_URL);
  • the LLM endpoint (LLM_BASE_URL), when an analyst generates a narrative;
  • webhook receivers, from the notification job;
  • the S3 endpoint of the archive;
  • a release manifestUrl that is not storage://.

Inbound, only the proxy port needs to be reachable: by agents, console users and the scheduler.

Before the stack leaves one machine

The development defaults are public. Before anything other than the local machine can reach the stack:

  • Replace every secret with a random value: BETTER_AUTH_SECRET, CRON_SECRET, NGINX_PROXY_SECRET (the same value on server and proxy) and the PostgreSQL password in both POSTGRES_PASSWORD and DATABASE_URL.
  • Never publish the application port. The proxy secret is what keeps a client from talking to the application directly with forged certificate headers, and it only works if the application is unreachable except through the proxy.
  • Do not publish PostgreSQL. Publish the proxy only on the address the lab uses (README-SETUP.md has an override file).
  • Replace the development CA and certificates with your own PKI.
  • Keep SYNTHAEA_SNAPSHOT_SIGNER unset outside labs: the test key is public.
  • Schedule the jobs; without them no case is grouped, no silent agent is noticed and no notification is sent.

Security model lists what remains undefended after that.