Standalone & Docker
apps/server is the server without Nuxt: Nitro 3 with the core as its only handler, configured entirely by environment variables. It reports itself as mongocamp-nitro-server.
Docker
Build the image from the repository root:
docker build -f apps/server/Dockerfile -t mongocamp-nitro-server .
docker run -p 8080:8080 -e CONNECTION_HOST=host.docker.internal mongocamp-nitro-serverThe image is distroless Node 24 (about 214 MB, of which the server is 3 MB). Images for Bun and Deno are below. It stops cleanly on docker stop (SIGTERM) and on DELETE /system.
Docker Compose
services:
mongodb:
image: mongo:7
volumes:
- mongodb-data:/data/db
mongocamp:
image: mongocamp-nitro-server
build:
context: .
dockerfile: apps/server/Dockerfile
ports:
- '8080:8080'
environment:
CONNECTION_HOST: mongodb
CONNECTION_DATABASE: mongocamp
CORS_ORIGINS_ALLOWED: '["http://localhost:3000"]'
DOCS_SWAGGER: 'true'
depends_on:
- mongodb
volumes:
mongodb-data:Open http://localhost:8080/docs for the API reference. The password of the first user admin is printed to the log of the first start:
docker compose logs mongocamp | grep -i passwordBun and Deno images
The same server also builds for Bun and Deno. The code, the API and the environment variables are identical; only the JavaScript runtime in the image differs.
| Dockerfile | Runtime | Nitro preset | Base image | Size |
|---|---|---|---|---|
apps/server/Dockerfile | Node 24 | node-server (default) | gcr.io/distroless/nodejs24-debian12:nonroot | ~214 MB |
apps/server/Dockerfile.bun | Bun 1.3 | bun | oven/bun:1.3-distroless | ~169 MB |
apps/server/Dockerfile.deno | Deno 2.6 | deno_server | denoland/deno:distroless-2.6.0 | ~205 MB |
docker build -f apps/server/Dockerfile.bun -t mongocamp-nitro-server:bun .
docker build -f apps/server/Dockerfile.deno -t mongocamp-nitro-server:deno .
docker run -p 8080:8080 -e CONNECTION_HOST=host.docker.internal mongocamp-nitro-server:bunHow they work:
- One build stage for all three. Each Dockerfile builds
apps/serverwith Node 24 and pnpm, as the Node image does. The only difference isNITRO_PRESET, which tells Nitro which server entry to generate:Bun.serveforbun,Deno.servefordeno_server,node:httpby default. The result is again a self-contained.outputwith nonode_modules, copied into a distroless runtime image. - Non-root. The Bun and Deno base images run as root, so both Dockerfiles switch to the distroless
nonrootuser (65532). - Shutdown.
docker stop(SIGTERM) andDELETE /systemclose the core and exit, as with Node. The Deno image runs undertini. - Deno permissions. The Deno image does not use
-A. It grants only--allow-net(listener, MongoDB),--allow-env(configuration),--allow-read(the bundled files) and--allow-sys(OS info for the MongoDB handshake). Add flags in your ownCMDif a declaration or plugin needs more, e.g.--allow-write. - Deno compatibility. Two Node behaviours are handled in the Deno image:
--unstable-bare-node-builtins: the MongoDB driver importsoswithout thenode:prefix. Without the flag Deno rejects that import, the driver silently sends a handshake without client metadata, and MongoDB refuses every connection withMissing required sub-document 'driver'.apps/server/deno-entry.mjsis the entry of the Deno image. It adds Node'sBroadcastChannel#unref()(called by the metrics library at import time, missing in Deno) and then importsserver/index.mjs.
Which one to use: the Node image is the reference. The contract and e2e suites run against Node, and it is what the Scala-compatible setup is verified with. Choose the Bun image for a smaller image and faster startup, or the Deno image when your platform standardizes on Deno or you want its permission sandbox. Test your own workload before you use either in production.
To use them in Docker Compose, set dockerfile: apps/server/Dockerfile.bun (or .deno) in the build section above.
Without Docker, the same presets work locally:
NITRO_PRESET=bun pnpm --filter mongocamp-nitro-server build
bun run apps/server/.output/server/index.mjs
NITRO_PRESET=deno_server pnpm --filter mongocamp-nitro-server build
cp apps/server/deno-entry.mjs apps/server/.output/
deno run --allow-net --allow-env --allow-read --allow-sys --unstable-bare-node-builtins apps/server/.output/deno-entry.mjsWithout Docker
pnpm install
pnpm --filter mongocamp-nitro-server build
CONNECTION_HOST=localhost node apps/server/.output/server/index.mjspnpm --filter mongocamp-nitro-server dev runs it with reload.
Logs
Every request is one JSON line on stdout, written by evlog, with the fields of the server under mongocamp (operation, user, collection, rows, error code). Collect them with the log driver of your platform. See Request Logging & Metrics.
{"method":"GET","path":"/mongodb/collections/books/documents","status":200,"durationMs":13,"mongocamp":{"operation":"listDocuments","user":"admin","collection":"books","rows":120},"level":"info","service":"mongocamp-nitro-server"}Listener
The server listens on SERVER_INTERFACE:SERVER_PORT (default 0.0.0.0:8080). Nitro's NITRO_HOST/NITRO_PORT (or HOST/PORT) win.
Declared collections
apps/server/collections/index.ts exports the declared collections of the standalone server; plugins/collections.ts registers them. The list is empty; an image built from this app adds its declarations there (and the schema library to the dependencies of apps/server):
// apps/server/collections/index.ts
import { z } from 'zod'
import { defineMongocampCollection } from '@sfxcode/mongocamp-server-core'
export const declarations = [
defineMongocampCollection({
name: 'orders',
schema: z.object({ customer: z.string(), qty: z.int().min(1) }),
validation: 'error',
}),
]Several instances
Instances can share a database. Users, roles, tokens, the token secret and the stored configurations live in it. Keep in mind:
- Jobs run in every instance; there is no lock between instances. Set
JOBS_ENABLED=falseon all instances but one. The built-in token cleanup is also safe to run concurrently. - Events are delivered within the instance that handled the request.
- Declared collections: every instance syncs the validators at its start; only the first one changes anything.
- With
AUTH_CACHE_DB, other instances keep their in-memory copy of a token for up to five minutes after it was revoked.
Upgrading
From an older MongoCamp server or image: see the migration guides.
