Deployment
Cognipeer supports multiple deployment strategies: standalone Docker, Kubernetes, and traditional Node.js process management.
Docker
Cognipeer runs in two common modes:
- SQLite mode for zero-dependency local, edge, or smaller self-hosted installations.
- MongoDB mode for higher-concurrency or centralized database deployments.
Build
docker build -t cognipeer-console:latest .The Dockerfile uses a multi-stage build:
- deps — Install npm dependencies (cached layer)
- builder — Build the Next.js application
- runner —
node:22image running as a non-root user (node)
Run
SQLite mode (default):
docker run -d \
--name cognipeer-console \
-p 3000:3000 \
-e JWT_SECRET="<random value, at least 32 characters>" \
-e PROVIDER_ENCRYPTION_SECRET="<a different random value, at least 32 characters>" \
-v console-data:/app/data \
cognipeer-console:latestMongoDB mode:
docker run -d \
--name cognipeer-console \
-p 3000:3000 \
-e DB_PROVIDER="mongodb" \
-e MONGODB_URI="mongodb://host.docker.internal:27017" \
-e JWT_SECRET="<random value, at least 32 characters>" \
-e PROVIDER_ENCRYPTION_SECRET="<a different random value, at least 32 characters>" \
cognipeer-console:latestThe image runs with NODE_ENV=production, so it refuses to start unless both secrets are valid. Generate each value once, for example with openssl rand -hex 32, and keep them: credentials stored under the old PROVIDER_ENCRYPTION_SECRET cannot be read with a new one, and a different JWT_SECRET signs everyone out.
On-prem MongoDB upgrade note
Cognipeer now supports an on-prem MongoDB deployment mode that keeps all Cognipeer data in a single database.
If you already run Cognipeer with on-prem MongoDB, treat the upgrade to v1.2.49 as a migration, not just an image replacement:
- Update your MongoDB deployment configuration for the single-database mode as needed (see Deployment mode for
DEPLOYMENT_MODEandMONGODB_SINGLE_DATABASE). - Run the required migration.
- Start the updated Cognipeer version only after the migration completes.
If you do not run Cognipeer with on-prem MongoDB, this release does not add a deployment migration for you.
Docker Compose
version: '3.8'
services:
gateway:
build: .
ports:
- "3000:3000"
environment:
DB_PROVIDER: sqlite
MAIN_DB_NAME: cgate_main
SQLITE_DATA_DIR: /app/data/sqlite
JWT_SECRET: "<random value, at least 32 characters>"
PROVIDER_ENCRYPTION_SECRET: "<a different random value, at least 32 characters>"
LOG_LEVEL: info
LOG_FORMAT: json
CACHE_PROVIDER: memory
healthcheck:
test: wget -q --spider http://localhost:3000/api/health/live || exit 1
interval: 30s
timeout: 5s
start_period: 10s
retries: 3
volumes:
console-data:If you want MongoDB instead, set DB_PROVIDER=mongodb, add MONGODB_URI, and provision the database separately. An installation on MongoDB defaults to the hosted (saas) deployment mode, which refuses provider endpoints on private networks unless the operator opens them for an organization; for an installation you run yourself also set DEPLOYMENT_MODE=onprem (see Deployment mode, including what it does to MONGODB_SINGLE_DATABASE).
Kubernetes
The community repository does not include a Helm chart, a helmfile or Kubernetes manifests. To run Cognipeer on Kubernetes from the community build, deploy the image built from the repository's Dockerfile (see Docker) with manifests of your own. Pages elsewhere in this guide that mention Helm values refer to the on-premises charts, which are not part of the community repository either. For those charts, or for help with a Kubernetes deployment, contact developer@cognipeer.com.
What the image gives your manifests:
- The container listens on port
3000and runs as the non-root usernode. GET /api/health/liveandGET /api/health/readyare public endpoints for liveness and readiness probes (see Health Probes below).- Node is the container's main process, so
SIGTERMreaches it and starts a graceful shutdown. - SQLite databases and local files are written under
/app/data. Mount a persistent volume there, or use MongoDB (DB_PROVIDER=mongodb). - Settings are environment variables; see the Configuration Reference.
JWT_SECRETandPROVIDER_ENCRYPTION_SECRETare required.
Health Probes
Example settings for the probes in your own manifests. The endpoints are described in the Health API.
livenessProbe:
httpGet:
path: /api/health/live
port: 3000
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /api/health/ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 10
failureThreshold: 3Sandbox on Kubernetes
Enterprise
This applies to the Enterprise charts. Sandboxes are an Enterprise module; see Sandbox on Kubernetes for the full behaviour.
The Kata chart (helm-chart-kata) runs each sandbox as a pod in a separate namespace (sandbox.namespace, the same value as env.SANDBOX_K8S_NAMESPACE). It has no Docker-in-Docker sidecar. What it sets up there:
- RBAC. A namespace-scoped
RoleandRoleBindingfor Cognipeer's service account (never aClusterRole;sandbox.rbac.create). The role coverspodsand, switchable one by one,pods/exec(allowExec),pods/logandpods/status(allowLog) andmetrics.k8s.io(allowMetrics). It also grantsnetworkpoliciesget, list, create and update (sandbox.rbac.allowNetworkPolicies, defaulttrue), so Cognipeer can block a sandbox's network, andpersistentvolumeclaimscreate, get, list and delete unlessenv.SANDBOX_K8S_PERSISTisoff, for persistent workspaces. - Network floor.
sandbox.networkPolicy.enabled(defaultfalse) adds a namespace-wide policy for sandbox pods: no ingress, egress only to DNS and to the destinations you list. A sandbox created with network blocked is covered by a separate deny-all policy that Cognipeer manages, so your policy leaves those pods out. Blocking needs a CNI that enforces NetworkPolicy; on a cluster that does not, setsandbox.rbac.allowNetworkPolicies: falseandenv.SANDBOX_K8S_BLOCK_NETWORK: "off". - Priority classes.
sandbox.priorityClasses.create(defaultfalse) createscognipeer-sandbox-interactive(value 1000) andcognipeer-sandbox-background(value 100), both withpreemptionPolicy: Never. Creating them needs cluster-scoped rights (scheduling.k8s.io/priorityclasses) for whoever installs the chart. Setenv.SANDBOX_K8S_PRIORITY_CLASS_INTERACTIVEand_BACKGROUNDto their names.
The Docker-in-Docker chart keeps the engine's data on emptyDir volumes: persistent sandboxes there do not survive the Cognipeer pod being replaced.
Standalone Node.js
Production Build
npm run build
npm startnpm start runs the custom Fastify server (src/server/index.ts) with NODE_ENV=production.
Process Manager
With PM2:
pm2 start npm --name cognipeer-console -- startEnvironment Configuration
Required Variables
| Variable | Description |
|---|---|
JWT_SECRET | JWT signing secret (min 32 chars) |
PROVIDER_ENCRYPTION_SECRET | Key that encrypts provider credentials at rest (min 32 chars, must differ from JWT_SECRET) |
Conditionally Required Variables
| Variable | Description |
|---|---|
MONGODB_URI | Required only when DB_PROVIDER=mongodb |
DEPLOYMENT_MODE | Set to onprem for a self-hosted installation on MongoDB (it defaults to saas there; SQLite installations default to onprem). It also changes the default of MONGODB_SINGLE_DATABASE to true: an installation that keeps its tenants in per-tenant databases sets MONGODB_SINGLE_DATABASE=false as well (see Deployment mode) |
Recommended Production Settings
# Logging
LOG_LEVEL=info
LOG_FORMAT=json
# Cache
CACHE_PROVIDER=redis
REDIS_URL=redis://redis:6379
# Security
CORS_ENABLED=true
CORS_ALLOWED_ORIGINS=https://app.yourdomain.com
# Performance
MONGODB_MIN_POOL_SIZE=5
MONGODB_MAX_POOL_SIZE=20
# Resilience
GATEWAY_RETRY_ENABLED=true
GATEWAY_CIRCUIT_BREAKER_ENABLED=true
# Shutdown
SHUTDOWN_TIMEOUT_MS=30000See the Configuration Reference for all available variables.
Graceful Shutdown
The control plane handles SIGTERM and SIGINT for graceful shutdown:
- Stop accepting new requests
- Drain pending async tasks
- Close cache connections
- Clear runtime pool
- Disconnect database
- Exit
Configure the timeout with SHUTDOWN_TIMEOUT_MS (default: 15s).
For Kubernetes, ensure terminationGracePeriodSeconds is greater than SHUTDOWN_TIMEOUT_MS:
spec:
terminationGracePeriodSeconds: 45
