Skip to content

Zero-Trust Production Deployment ​

The infra/compose/prod.yml stack (name: lattice-dx-prod) packages the hardened production topology for LatticeDX 0.4.2. It combines east-west segmentation across five Docker networks, immutable @sha256 digest pinning across every OCI image, least-privilege PostgreSQL roles (nocobase_app), and OIDC/PKCE enforcement at the ingress boundary.

1. Five-Network Segmentation and Container Hardening ​

Every service in infra/compose/prod.yml inherits the x-hardened anchor (restart: unless-stopped, security_opt: [no-new-privileges:true], cap_drop: [ALL]) and receives only the exact Linux capabilities (cap_add) required for its process. Four of the five networks are declared internal: true, blocking unrouted outbound internet access and lateral movement from data, scanner, or shop-floor OT containers.

Docker NetworkinternalAttached ServicesSecurity Boundary
edgefalsecaddy, keycloak, gateway, nocobasePublic HTTPS ingress (80, 443 TCP/UDP) terminated exclusively by Caddy
apptruecaddy, gateway, keycloak, keycloak-config-cli, nocobase, redis, file-scanner, orion-ld, n8n, otel-collector, prometheus, grafana, gotenberg, noderedInternal HTTP API control plane, OIDC backchannel, OTLP traces, and workflow bridges
datatruepostgres, nocobase-db, redis, rustfs, orion-mongo, keycloak, nocobase, file-scanner, orion-ld, n8n, otel-collector, prometheus, grafanaRelational databases, pgvector embeddings, Valkey store, S3 object storage, and MongoDB
scannertrueclamav, file-scannerAir-gapped antivirus scanning plane isolated from edge and data
iiot-nettruemosquitto, nodered, nocobaseIsolated shop-floor MQTT broker and Node-RED protocol bridge

Stateless services (file-scanner, otel-collector, prometheus, gotenberg) run with read_only: true and scoped tmpfs mounts (noexec,nosuid). RustFS runs with RUSTFS_CONSOLE_ENABLE: "false" so S3 storage stays strictly internal on data:9000.


2. Pinned @sha256 OCI Image Inventory ​

All OCI images in infra/compose/prod.yml are pinned by immutable @sha256 digests to prevent tag-mutation supply-chain drift. @dx/file-scanner builds locally from apps/file-scanner/Dockerfile.

Core Services (Always Enabled) ​

ServicePinned Image Digest (@sha256)Resource Limits
caddycaddy:2.10-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d256m / 0.5 CPU
gatewayapache/apisix:3.19.0-debian@sha256:9a7e45dc943fbf10ec916d1232bae4cda9302ae28a4696cfb83c2da01d261141512m / 1.0 CPU
keycloakquay.io/keycloak/keycloak:26.8.2@sha256:7e66a96e4739239070aeaf72e4c5decf0f7f682cfc725b9f7ea2b336eaba38b31536m / 1.5 CPU
postgrespostgres:16.16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d1536m / 1.5 CPU
nocobase-dbpgvector/pgvector:0.8.1-pg16@sha256:33198da2828a14c30348d2ccb4750833d5ed9a44c88d840a0e523d74171203372048m / 2.0 CPU
redisvalkey/valkey:8.1-alpine@sha256:9971099af41c36e887aabdfe22b80c0fe45df949163dfc9cb434febc57cfc3fc640m / 0.5 CPU
rustfsrustfs/rustfs:1.0.6@sha256:ee717072290bec9b11abfc0365f8310b00df1cd9b3639943edae47bdef05044a1024m / 1.0 CPU
clamavclamav/clamav:1.5.5@sha256:12177441d1b40cef3c47b44c4090d59d4babc4c67bedd5af0fa315e603aa6dd82048m / 1.0 CPU
file-scannerBuilt from apps/file-scanner/Dockerfile (read_only: true)256m / 0.5 CPU
orion-mongomongo:8.0@sha256:479e85ced54ffb8a40dade1dcde2da2a9ae858515b9415e9cc54bfb8f0575d011024m / 1.0 CPU
orion-ldfiware/orion-ld:1.12.0@sha256:f562a93ed84cccae05063688e1c3605f75060d0c7b9cd004561eec43bcbd613b768m / 1.0 CPU
nocobasenocobase/nocobase:2.2.50@sha256:04b75164936e7314ef74d82844bc56c9f34ed7ff1ca976ca53ffac2d3c88d7772048m / 2.0 CPU

Optional Profile Services (--profile) ​

ProfileServicePinned Image Digest (@sha256)Resource Limits
iam-synckeycloak-config-cliadorsys/keycloak-config-cli:6.5.1-26@sha256:1b22dfaa9ae0c71f74b0342f9221a6510f272da5def683dbba26a98e6b1b1411512m / 0.5 CPU
n8nn8nn8nio/n8n:2.48.1@sha256:5e022f23ef9eaac3f51467e021610c218ed7eb5b41a05edb388ef1c8e00e009f1024m / 1.0 CPU
observabilityotel-collectorotel/opentelemetry-collector-contrib:0.123.0@sha256:e39311df1f3d941923c00da79ac7ba6269124a870ee87e3c3ad24d60f8aee4d2512m / 0.5 CPU
observabilityprometheusprom/prometheus:v3.3.0@sha256:339ce86a59413be18d0e445472891d022725b4803fab609069110205e79fb2f1512m / 0.5 CPU
observabilitygrafanagrafana/grafana-oss:11.5.8@sha256:b8121de93047fd77c77de806bae9706e7d60de21c3bd5381a5db0167f94c6a48512m / 0.5 CPU
pdfgotenberggotenberg/gotenberg:8.20.1@sha256:cda4386c7ed38f18bc6897828be01ba7361c99929a5c84ec5e293d7916e29bac768m / 1.0 CPU
iiotmosquittoeclipse-mosquitto:2.0.21@sha256:94f5a3d7deafa59fa3440d227ddad558f59d293c612138de841eec61bfa4d353256m / 0.5 CPU
iiotnoderednodered/node-red:4.0.9@sha256:0b295b3a14c512548567ca99db631bc37b23bfc79fd009ee8248a610fafdb4b5512m / 0.5 CPU

3. Edge Proxy: Caddy, Apache APISIX, and Keycloak OIDC/PKCE ​

Incoming client traffic passes through three sequential enforcement layers before reaching the NocoBase host or backend services:

Edge LayerConfiguration FileSecurity & Routing Policy
Caddy 2.10infra/config/caddy/CaddyfileTerminates TLS for ${LATTICE_DOMAIN}, ${KEYCLOAK_DOMAIN}, and ${N8N_DOMAIN} (including HTTP/3 on 443/udp), strips the Server header, and injects Strict-Transport-Security (max-age=63072000; includeSubDomains; preload), X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy, and Permissions-Policy. Paths under /api/* and /.well-known/agent-card.json route to gateway:9080 with flush_interval -1 for SSE streaming, while portal UI routes forward to nocobase:80 where Nginx applies per-response nonce CSP for /v/form/* and /v/track/*.
Apache APISIX 3.19.0infra/config/apisix/apisix.prod.yamlAttaches X-Request-Id, enforces strict CORS against ${LATTICE_ALLOWED_ORIGIN}, and applies Valkey-backed limit-count throttling (120 req/60s on public, auth, and MCP routes; 300 req/60s on IIoT ingest endpoints; 240 req/60s on /api/*). Requests to /api/dxos-oidc/* undergo openid-connect validation (bearer_only: true, use_jwks: true, ssl_verify: true) against Keycloak JWKS.
Keycloak 26.8.2infra/config/keycloak/lattice-realm.prod.jsonConfigures the lattice realm with bruteForceProtected: true (5-attempt lockout), TOTP MFA, and a 12-character minimum password policy. The public dx-native client enforces PKCE S256 (standardFlowEnabled: true, directAccessGrantsEnabled: false). @latticedx/plugin-enterprise-auth executes the 4-step start -> callback -> finish -> backchannelLogout lifecycle and explicitly skips privileged roles (ldx_admin, allowConfigure, pm*) during group-to-role mapping.

4. Valkey 8.1 Partitioning (DB 0 / DB 1 / DB 2) ​

valkey/valkey:8.1-alpine (BSD-3-Clause) runs with --appendonly yes, --requirepass, --maxmemory 512mb, and allkeys-lru eviction, isolating state across three logical databases plus APISIX rate-limit counters:

Valkey 8.1 Logical Database Partitioning
ParameterTypeDefaultDescription
DB 0 (CACHE_REDIS_URL)
Cacheredis://:...@redis:6379/0NocoBase application cache store when CACHE_DEFAULT_STORE=redis.
DB 1 (PUBSUB_ADAPTER_REDIS_URL)
Pub/Subredis://:...@redis:6379/1PubSub channel latticedx:surface-updates bridging record/flow mutations to /api/dxosAi:surfaceEvents SSE.
DB 2 (DX_NATIVE_AUTH_SESSION_REDIS_URL)
Session/PKCEredis://:...@redis:6379/2Stores OIDC PKCE state (300s TTL), one-time tickets (60s TTL), and backchannelLogout revocation keys (24h TTL).
APISIX limit-count
Rate Limitpolicy: redisTracks per-IP rate-limit windows across public, auth, MCP, IIoT, and core API routes.

Valkey Streams are not used for asynchronous delivery. The transactional outbox tables (latticeContextOutbox, latticeEventBus) reside in PostgreSQL and drain via FOR UPDATE SKIP LOCKED.


5. Non-Root nocobase_app Role and Least-Privilege Databases ​

During initial nocobase-db bootstrap, infra/config/postgres/init-nocobase-db.sh creates the non-superuser runtime role nocobase_app and aborts if NOCOBASE_APP_DB_USER matches POSTGRES_USER:

sql
CREATE ROLE nocobase_app LOGIN PASSWORD '...'
  NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS;
ALTER DATABASE nocobase OWNER TO nocobase_app;
REVOKE ALL ON DATABASE nocobase FROM PUBLIC;
REVOKE CREATE ON SCHEMA public FROM PUBLIC;

Because nocobase_app carries NOSUPERUSER and NOBYPASSRLS, PostgreSQL enforces ENABLE and FORCE ROW LEVEL SECURITY across all 56 static tables and dynamic latticeCustom* tables even though nocobase_app owns the nocobase database. Paired with DX_PG_RLS_SESSION=true, every transaction-scoped query stays confined to app.current_org.


6. Step-by-Step Production Rollout ​

Step 1: Prepare .env.prod and Validate Compose ​

Copy infra/compose/prod.env.example outside Git, replace all CHANGE_ME_* secrets, and verify Compose interpolation:

bash
cp infra/compose/prod.env.example .env.prod
chmod 600 .env.prod
docker compose --env-file .env.prod -f infra/compose/prod.yml \
  --profile iam-sync --profile n8n --profile iiot --profile observability --profile pdf \
  config --quiet

Step 2: Build the 7 Plugins on Host and Start the Stack ​

prod.yml bind-mounts the 7 plugins/nocobase/* directories read-only (:ro) into /app/nocobase/node_modules/@latticedx/*. Build all dist/ bundles and install openid-client inside plugin-enterprise-auth before starting containers:

bash
pnpm install --frozen-lockfile
npm ci --prefix plugins/nocobase/plugin-enterprise-auth --ignore-scripts --no-audit --no-fund
node plugins/nocobase/action-bridge/build.mjs
node plugins/nocobase/plugin-lattice-foundation/scripts/build.mjs
node plugins/nocobase/plugin-enterprise-auth/build.mjs
node plugins/nocobase/plugin-dxos-para/build.mjs
node plugins/nocobase/plugin-dxos-blocks/build.mjs
node plugins/nocobase/plugin-dxos-studio/build.mjs
node plugins/nocobase/plugin-dxos-ai/build.mjs

docker compose --env-file .env.prod -f infra/compose/prod.yml \
  --profile iam-sync --profile n8n --profile iiot --profile observability --profile pdf \
  up -d --build

Step 3: Sync Keycloak Realm and Enable Plugins ​

Once postgres, nocobase-db, keycloak, clamav, and nocobase report healthy, ensure the iam-sync job has completed, register the 7 plugins, and run yarn nocobase upgrade:

bash
docker compose --env-file .env.prod -f infra/compose/prod.yml --profile iam-sync up --abort-on-container-exit

for pkg in \
  @latticedx/plugin-action-bridge \
  @latticedx/plugin-lattice-foundation \
  @latticedx/plugin-enterprise-auth \
  @latticedx/plugin-dxos-para \
  @latticedx/plugin-dxos-blocks \
  @latticedx/plugin-dxos-studio \
  @latticedx/plugin-dxos-ai; do
  docker compose --env-file .env.prod -f infra/compose/prod.yml exec -T nocobase yarn nocobase pm add "$pkg" || true
  docker compose --env-file .env.prod -f infra/compose/prod.yml exec -T nocobase yarn nocobase pm enable "$pkg"
done

docker compose --env-file .env.prod -f infra/compose/prod.yml exec -T nocobase yarn nocobase upgrade

Step 4: Verify Ingress Health and PITR Readiness ​

Confirm container health and test public routing through Caddy and APISIX:

GET/health
Public (APISIX rewrite -> /api/dxos:health)
Verifies TLS routing through Caddy, APISIX rate-limiting, and NocoBase runtime health.
bash
docker compose --env-file .env.prod -f infra/compose/prod.yml ps
curl -fsS "https://<LATTICE_DOMAIN>/health"

# Verify Prometheus scrape endpoint with DX_METRICS_TOKEN
curl -fsS -H "Authorization: Bearer <DX_METRICS_TOKEN>" "https://<LATTICE_DOMAIN>/api/dxos:metrics" | head -n 20

Both postgres and nocobase-db start with wal_level=replica, archive_mode=on, archive_timeout=300, wal_compression=on, and pitr-archive.sh archiving gzipped WAL segments. Follow Upgrading and Backup and PITR to schedule regular backups and recovery drills.


Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)