Skip to content

PKI Manager - Docker Deployment Guide

Source: DEPLOYMENT.md

PKI Manager uses Docker for containerized deployment with the following components:

  • Backend: Fastify + tRPC API server (Node.js 22 Alpine)
  • Frontend: React SPA served by Nginx (Alpine)
  • KMS: Cosmian Key Management System (official image)

All images are published exclusively to GitHub Container Registry (ghcr.io).

Deploying the SSH Certificate Manager to real servers? See the SSH guides: concept · host & client setup · Ansible role. Hosts need NTP and outbound access to the public trust/KRL endpoints (/ssh/..., /krl/<caId>.bin).

  • Docker 20.10+ and Docker Compose 2.0+
  • (Optional) .env file for custom configuration
  • For CI/CD: GitHub repository with GHCR access
  1. Clone and navigate to the project:

    Terminal window
    cd pki-manager/docker

    The Compose file is docker/docker-compose.yml: run the docker-compose commands below from the docker/ directory (or add -f docker/docker-compose.yml from the repository root).

  2. Create .env file (optional, uses defaults if not present):

    Terminal window
    cp .env.example .env
    # Edit .env with your preferred settings
  3. Create the backend data folder (the backend runs as uid 1001; a folder that Docker creates is owned by root and the backend fails with SqliteError: unable to open database file):

    Terminal window
    mkdir -p ../pki && sudo chown 1001:1001 ../pki
  4. Build and start all services:

    Terminal window
    docker-compose up --build
  5. Access the application:

Build backend only (from the repository root):

Terminal window
docker build -f docker/Dockerfile --target backend -t pki-manager-backend:dev .

Build frontend only:

Terminal window
docker build -f docker/Dockerfile --target frontend \
--build-arg VITE_API_URL=http://localhost:3000/trpc \
-t pki-manager-frontend:dev .
Terminal window
# Start services in detached mode
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Stop and remove volumes (⚠️ deletes data)
docker-compose down -v
# Rebuild specific service
docker-compose up --build backend
# Execute commands in running container
docker-compose exec backend sh

Create a .env file with production values:

Terminal window
# Image Configuration
IMAGE_TAG=latest # or specific version like v1.0.0
# Network Configuration
BACKEND_EXTERNAL_PORT=3000
FRONTEND_EXTERNAL_PORT=80
# Backend Configuration
NODE_ENV=production
FRONTEND_URL=https://your-domain.com
# KMS Configuration
KMS_URL=http://kms:9998
KMS_API_KEY=your-secure-api-key # Optional
# Frontend Build Configuration
VITE_API_URL=https://your-domain.com/trpc
Terminal window
# Login to GitHub Container Registry
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Pull images
docker-compose pull
Terminal window
# Start services
docker-compose up -d
# Verify health
docker-compose ps
docker-compose logs

The backend container entrypoint (docker/docker-entrypoint.sh) runs the database migrations automatically on every start, so no manual step is needed. To run them by hand (for example to inspect the output):

Terminal window
docker exec pki-backend node /app/backend/dist/db/migrate.js

Expected output:

Running migrations...
Migrations folder: /app/backend/dist/db/migrations
Migrations completed successfully!

Note: The production container only includes compiled JavaScript. The standard pnpm db:migrate command won’t work. Always use the direct node command above.

Step 5: Configure Reverse Proxy (Optional)

Section titled “Step 5: Configure Reverse Proxy (Optional)”

Example Nginx configuration for production:

/etc/nginx/sites-available/pki-manager
server {
listen 443 ssl http2;
server_name your-domain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# Frontend
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Backend API
location /trpc {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

Client IPs behind a reverse proxy (TRUST_PROXY)

Section titled “Client IPs behind a reverse proxy (TRUST_PROXY)”

Behind a proxy, the backend sees the proxy as the client, so every audit row (audit_log.ip_address) and every per-IP limit (KRL fetches, the anonymous external-API rejection budget) uses the proxy’s address. Set TRUST_PROXY on the backend to the addresses of the proxies that forward to it, so it takes the client IP from X-Forwarded-For:

Value Meaning
unset / false Ignore proxy headers (default; correct when clients connect directly)
10.222.35.0/24,172.18.0.5 Trust only these peers (IPs/CIDRs; also loopback, linklocal, uniquelocal). Recommended
1..10 Trust that many hops whatever the peer: only safe if the backend is unreachable except through them

true (trust anyone) is rejected and so are malformed entries, so the backend fails at startup instead of silently ignoring a typo. List every proxy hop that can reach the backend: e.g. the edge proxy’s network and the frontend nginx, which also forwards /cas/*, /krl/* and /ssh/zones/*. Each proxy must send X-Forwarded-For $proxy_add_x_forwarded_for (the example above and docker/nginx.conf do). Never list networks whose other containers are untrusted: any listed peer can choose the recorded client IP.

Check it: make a request that will be rejected, such as curl https://your-domain.com/api/v1/external/health without a token, then look at the newest external.reject row in the audit log. Its IP must be your public address, not a Docker network address.

Single-Origin Edge Proxy & the /ssh/* Namespace Collision

Section titled “Single-Origin Edge Proxy & the /ssh/* Namespace Collision”

Read this if you serve the SPA and the backend on ONE origin (one host/port behind a single reverse proxy or ingress — e.g. https://pki.example.com), rather than the two-port model (:8080 frontend, :3000 backend) used by the default compose file.

/ssh/* is claimed by both layers:

  • The frontend SPA owns /ssh/* as a UI URL namespace — TanStack Router pages such as /ssh/cas, /ssh/hosts, /ssh/krl, /ssh/users, /ssh/principals.
  • The backend serves public, unauthenticated trust material at the server ROOT under /ssh/... (plus /krl/..., /crl/..., /cas/....pem) — the files that hosts, the Ansible role, and krl-client fetch.

With a naive single-origin edge (SPA fallback catching everything, or the frontend container serving / with no backend proxy), GET /ssh/host-ca-keys returns the SPA’s index.html instead of the CA key material. Symptom observed in production: /health and /crl/* reach the backend, but /ssh/host-ca-keys returns <!doctype html>. The two-port compose model hides this because the backend and frontend are different origins.

The fix (already applied to docker/nginx.conf)

Section titled “The fix (already applied to docker/nginx.conf)”

The frontend container’s nginx is now a single-origin edge proxy: it proxies the specific backend-owned paths to http://backend:3000 and lets everything else (including the SPA’s own /ssh/cas, /ssh/hosts, … UI routes) fall through to the SPA. The proxy location blocks are placed before the location / SPA fallback; nginx evaluates regex locations (in order) ahead of the prefix fallback, so the specific backend /ssh/... paths win while the SPA keeps the rest. This is purely a proxy/routing change — the backend routes are unchanged, so external consumers (Ansible role, krl-client) keep working against the same paths.

Backend-owned paths that MUST be routed to the backend:

Path pattern What it serves
/api/ (prefix) REST + OpenAPI/Swagger API
/trpc (prefix) tRPC endpoint (frontend RPC)
^/crl/ Public CRL downloads (/crl/<caId>.crl|.der)
^/cas/[^/]+\.(pem|crt|cer|der)$ Public CA-certificate downloads
^/krl/ Public SSH KRL (/krl/<caId>.bin|.json, /krl/hosts/<id>.bin|.json)
^/ssh/zones/[^/]+/(host-ca-keys|trusted-user-ca-keys|cert-authority)$ Zone-scoped SSH trust anchors
^/ssh/(host-ca-keys|trusted-user-ca-keys|cert-authority)$ SSH trust anchors + known_hosts lines (default zone)
^/ssh/cas/[^/]+/ca\.pub$ A single SSH CA’s public key
^/ssh/hosts/[^/]+/(cert\.pub|sshd-config)$ A host’s cert + sshd drop-in

Everything not matched above (/, /assets/*, /ssh/cas, /ssh/hosts, /ssh/krl, /ssh/users, …) is served by the SPA. The container’s local /health (used by the frontend healthcheck) stays local.

The exact nginx rules (standard proxy_set_header Host/X-Real-IP/X-Forwarded-For/X-Forwarded-Proto headers included) live in docker/nginx.conf. For a single-origin deployment, point the SPA at the same origin by setting VITE_API_URL=/trpc (so the browser hits the edge, not :3000 directly).

Terminal window
docker compose -f docker/docker-compose.yml up -d
# Backend trust material through the single origin (NOT HTML):
curl -s http://localhost:8080/ssh/host-ca-keys | head # -> ssh-...-ca key line(s)
curl -s http://localhost:8080/krl/<caId>.bin -o /dev/null -w '%{content_type}\n' # -> application/octet-stream
curl -s http://localhost:8080/crl/<caId>.crl | head -1 # -> -----BEGIN X509 CRL-----
# SPA still owns its UI routes (IS HTML):
curl -s http://localhost:8080/ssh/cas | head -1 # -> <!doctype html>

Using a different edge proxy (Traefik / Caddy / Kubernetes ingress)

Section titled “Using a different edge proxy (Traefik / Caddy / Kubernetes ingress)”

If you terminate on something other than this nginx (Traefik, Caddy, HAProxy, an ingress controller, a cloud LB), you must replicate the same path routing to the backend, or the /ssh/* trust-material routes will be shadowed by the SPA again. Route the nine path patterns in the table above to the backend service (backend:3000) and send everything else to the frontend. Sketches:

Caddy

pki.example.com {
@backend {
path /api/* /trpc*
path /crl/* /krl/*
path_regexp cas ^/cas/[^/]+\.(pem|crt|cer|der)$
path /ssh/host-ca-keys /ssh/trusted-user-ca-keys /ssh/cert-authority
path_regexp sshzone ^/ssh/zones/[^/]+/(host-ca-keys|trusted-user-ca-keys|cert-authority)$
path_regexp sshpub ^/ssh/cas/[^/]+/ca\.pub$
path_regexp sshhost ^/ssh/hosts/[^/]+/(cert\.pub|sshd-config)$
}
reverse_proxy @backend backend:3000
reverse_proxy frontend:8080
}

Traefik / ingress — create a higher-priority router/rule matching those exact paths/regexes to the backend service, and a default (lower priority) router to the frontend. In Kubernetes, use Exact/ImplementationSpecific path types (or a regex-capable ingress) for the /ssh/..., /krl/, /crl/, /cas/....pem, /api/, and /trpc routes to the backend Service, with a catch-all / to the frontend.

None! The stack runs with sensible defaults. However, you should customize for production.

See docker/.env.example for full list. Key variables:

Variable Default Description
IMAGE_TAG latest Docker image tag to use
BACKEND_EXTERNAL_PORT 3000 Host port for backend API
FRONTEND_EXTERNAL_PORT 8080 Host port for frontend
KMS_EXTERNAL_PORT 9998 Listed in docker/.env.example, but docker/docker-compose.yml does not publish the KMS port
NODE_ENV production Node environment
FRONTEND_URL http://localhost:8080 Frontend URL for CORS
DATABASE_PATH /app/backend/data/pki.db Database file path (in container)
KMS_URL http://kms:9998 KMS service URL
KMS_API_KEY (empty) Optional KMS authentication
CRL_DISTRIBUTION_URL http://localhost:3000/crl Public URL for CRL distribution points
TRUST_PROXY (empty) Reverse proxies allowed to set the client IP (details)
VITE_API_URL http://localhost:3000/trpc API URL for frontend

PKI Manager supports OpenID Connect (OIDC) authentication with any compliant provider (Keycloak, Auth0, Okta, Azure AD, etc.). Authentication is optional - leave OIDC variables unset to run without authentication.

Add these to your .env file:

Variable Example Description
OIDC_ISSUER https://keycloak.example.com/realms/pki OIDC provider base URL (must match token iss claim)
OIDC_AUDIENCE pki-web,pki-service Expected audience claim(s), comma-separated
OIDC_ROLES_SOURCE token Role source: token (default) or userinfo
OIDC_ROLES_CLAIM realm_access.roles Path to roles in the selected claim source; groups for group-based roles
OIDC_DISCOVERY_BASE_URL (optional) Override URL for fetching OIDC discovery (for Docker networking)

Provider-specific issuer URLs:

  • Keycloak: https://keycloak.example.com/realms/your-realm
  • Auth0: https://your-tenant.auth0.com
  • Okta: https://your-org.okta.com
  • Azure AD: https://login.microsoftonline.com/{tenant-id}/v2.0

Provider-specific roles claim paths:

  • Keycloak: realm_access.roles
  • Auth0: permissions or custom namespace
  • Okta: groups
  • Azure AD: roles
Variable Example Description
VITE_OIDC_AUTHORITY https://keycloak.example.com/realms/pki Same as backend OIDC_ISSUER
VITE_OIDC_CLIENT_ID pki-web Public OIDC client ID (PKCE-enabled)
VITE_OIDC_SCOPE openid profile email OAuth2 scopes (optional, defaults shown)

Important for Docker: Frontend OIDC variables are build-time only. You must either:

  1. Rebuild the image with --build-arg VITE_OIDC_AUTHORITY=... (requires Dockerfile modification), or
  2. Use runtime config by mounting a custom config.json (see below)

For production Docker deployments, mount a custom config.json to configure OIDC without rebuilding:

Terminal window
# Create config.json with OIDC settings
cat > docker/config.json << 'EOF'
{
"apiUrl": "https://api.pki.example.com/trpc",
"oidc": {
"authority": "https://keycloak.example.com/realms/pki",
"clientId": "pki-web",
"scope": "openid profile email"
}
}
EOF

The default docker/docker-compose.yml already mounts it:

services:
frontend:
volumes:
- ./config.json:/usr/share/nginx/html/config.json:ro

For detailed step-by-step instructions with screenshots, see KEYCLOAK.md.

For a deep dive into how OIDC works (public clients, PKCE, token validation), see OIDC.md.

Quick summary:

  1. Create a Realm (e.g., pki-manager)

  2. Create a Client for the SPA:

    • Client ID: pki-web
    • Client authentication: Off (public client)
    • Standard flow: Enabled (for PKCE)
    • Valid redirect URIs: https://pki.example.com/*
    • Web origins: https://pki.example.com
  3. Create a Client for M2M (optional):

    • Client ID: pki-service
    • Client authentication: On (confidential)
    • Service accounts roles: Enabled
  4. Create a test user with username and password

  5. Configure .env:

Terminal window
# Backend
OIDC_ISSUER=https://keycloak.example.com/realms/pki-manager
OIDC_AUDIENCE=pki-web,pki-service
OIDC_ROLES_CLAIM=realm_access.roles
# Frontend (build-time or runtime)
VITE_OIDC_AUTHORITY=https://keycloak.example.com/realms/pki-manager
VITE_OIDC_CLIENT_ID=pki-web

To run without authentication, simply leave the OIDC variables unset or empty:

Terminal window
# Backend - no OIDC_ISSUER = all endpoints public
# OIDC_ISSUER=
# Frontend - no VITE_OIDC_AUTHORITY = no login required
# VITE_OIDC_AUTHORITY=

For production, use Docker secrets or environment variable injection:

The backend reads KMS_API_KEY from its environment only (*_FILE variables are not supported), so inject it from your secret store into the environment:

docker-compose.override.yml
services:
backend:
environment:
- KMS_API_KEY=${KMS_API_KEY}

The .github/workflows/docker-build.yml workflow:

  1. Triggers: On main branch pushes, tags (v*.*.*), and PRs
  2. Builds: Both backend and frontend images
  3. Publishes: Only to ghcr.io (never Docker Hub)
  4. Tags: Semantic versioning, branch names, git SHA
  5. Security: Trivy vulnerability scanning, SLSA attestation
  6. Platform: Builds for linux/amd64
  1. Enable GHCR:

    • Go to repository Settings → Actions → General
    • Under “Workflow permissions”, enable “Read and write permissions”
  2. Configure Variables (Settings → Secrets and variables → Actions → Variables):

    • VITE_API_URL: Production API URL (e.g., https://api.your-domain.com/trpc)
  3. Create Release:

    Terminal window
    git tag v1.0.0
    git push origin v1.0.0

Images are published to:

  • ghcr.io/YOUR_ORG/pki-manager-web/backend:TAG
  • ghcr.io/YOUR_ORG/pki-manager-web/frontend:TAG

Available tags:

  • latest - Latest main branch build
  • 1.0.0, 1.0, 1 - Semantic version tags (from v1.0.0 tags, without the v)
  • main - Latest build of a branch
  • sha-abc1234 - Commit SHA (short)
  • pr-123 - Pull request builds

PKI Manager includes comprehensive E2E tests for Role-Based Access Control (RBAC). Tests can run against a local Docker environment or production.

E2E stack: Playwright on the host drives frontend, backend and Keycloak containers; backend uses the KMS

The backend uses OIDC_DISCOVERY_BASE_URL to fetch OIDC configuration from the Docker network (keycloak:8080) while validating tokens against the issuer URL that browsers use (localhost:58180).

The docker-compose.e2e.yml provides a complete isolated environment for testing:

Terminal window
# 1. Build images with latest code (if you made changes)
docker build --target backend -t ghcr.io/oriolrius/pki-manager-web/backend:latest -f docker/Dockerfile .
docker build --target frontend -t ghcr.io/oriolrius/pki-manager-web/frontend:latest -f docker/Dockerfile .
# 2. Start the E2E environment (includes Keycloak with pre-configured test users)
docker compose -f docker/docker-compose.e2e.yml up -d
# 3. Wait for all services to be healthy (~60-90 seconds for Keycloak)
docker compose -f docker/docker-compose.e2e.yml ps
# 4. Run the RBAC tests
pnpm playwright test tests/e2e-rbac.spec.ts --reporter=list
# 5. Cleanup when done
docker compose -f docker/docker-compose.e2e.yml down -v

The E2E environment includes pre-configured test users in Keycloak:

Username Password Role Description
testadmin Test123! admin Full access - can create, revoke, delete CAs and certificates
testuser Test123! user Limited access - can view and issue certificates, cannot perform admin operations
Service URL Description
Frontend http://localhost:58080 PKI Manager UI
Backend API http://localhost:53000 tRPC API
Keycloak http://localhost:58180 Identity Provider (admin/admin for Keycloak console)
KMS Internal only Cosmian Key Management System

To test against a production environment:

Terminal window
E2E_TARGET=production pnpm playwright test tests/e2e-rbac.spec.ts --reporter=list

Or with custom URLs:

Terminal window
E2E_FRONTEND_URL=https://pki.example.com \
E2E_ADMIN_USER=testadmin \
E2E_ADMIN_PASSWORD=Test123! \
pnpm playwright test tests/e2e-rbac.spec.ts
Variable Default Description
E2E_TARGET local Target environment: local or production
E2E_FRONTEND_URL (from target) Override frontend URL
E2E_ADMIN_USER testadmin Admin test user
E2E_ADMIN_PASSWORD Test123! Admin password
E2E_TEST_USER testuser Regular test user
E2E_TEST_PASSWORD Test123! Regular user password

Problem: TypeScript compilation errors during build

Solution: Ensure TypeScript type errors are fixed in the codebase:

Terminal window
cd backend && pnpm typecheck

Problem: Cannot pull from ghcr.io

Solution:

Terminal window
# Create personal access token with packages:read scope
# Then login:
echo $GITHUB_TOKEN | docker login ghcr.io -u YOUR_USERNAME --password-stdin

Check service health:

Terminal window
docker-compose ps
docker inspect pki-backend --format='{{.State.Health.Status}}'

View detailed logs:

Terminal window
docker-compose logs backend
docker-compose logs frontend
docker-compose logs kms

Problem: Database locked or corrupted

Solution:

Terminal window
# Stop services
docker-compose down
# Remove the bind-mounted data directory (⚠️ deletes data)
rm -rf ../pki
# Restart
docker-compose up -d

Problem: Backend cannot connect to KMS

Check network:

Terminal window
docker-compose exec backend ping kms
docker-compose exec backend wget -qO- http://kms:9998/health

Verify KMS is healthy:

Terminal window
docker-compose ps kms

Problem: Port already in use

Solution: Change ports in .env:

Terminal window
BACKEND_EXTERNAL_PORT=3001
FRONTEND_EXTERNAL_PORT=8081

Problem: “no such table: audit_log” error

Solution: Database migrations didn’t run. The E2E docker-compose automatically runs migrations on startup. If using a custom setup:

Terminal window
docker exec pki-e2e-backend node /app/backend/dist/db/migrate.js

Problem: OIDC token validation fails in Docker

Solution: Ensure OIDC_DISCOVERY_BASE_URL is set for Docker networking:

docker-compose.e2e.yml
environment:
- OIDC_ISSUER=http://localhost:58180/realms/pki-e2e
- OIDC_DISCOVERY_BASE_URL=http://keycloak:8080/realms/pki-e2e

Problem: Keycloak healthcheck fails (timeout)

Solution: Keycloak 26+ takes ~60-90 seconds to start. The healthcheck has a 90-second start period. Check logs:

Terminal window
docker logs pki-e2e-keycloak

Problem: Tests fail with “Login button not found”

Solution: Wait for all services to be healthy before running tests:

Terminal window
docker compose -f docker/docker-compose.e2e.yml ps
# All services should show "healthy" status

Security Checklist:

  • Check the migrations ran (the backend entrypoint runs them): docker-compose logs backend
  • Set NODE_ENV=production
  • Configure FRONTEND_URL with production domain
  • Set strong KMS_API_KEY
  • Configure OIDC authentication (see OIDC Configuration)
  • Use HTTPS with reverse proxy
  • Configure firewall rules
  • Set up backup strategy for volumes
  • Enable Docker restart policies (already configured)
  • Monitor resource limits
  • Review security scan results
  • CPU: 2 cores
  • RAM: 4GB
  • Disk: 10GB
  • CPU: 4+ cores
  • RAM: 8GB+
  • Disk: 50GB+ (SSD)

Not set in docker/docker-compose.yml; add them in an override file if needed:

services:
backend:
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M

Optional SCEP gateway (separate deployment)

Section titled “Optional SCEP gateway (separate deployment)”

The SCEP gateway is a separate device-facing service. Deploy the integration foundation (migration 0010) first; the gateway needs its integration token and external enrollment-state endpoints. It adds no second backend. Use scep/compose.yml for an existing installation or the docker/docker-compose.scep.yml overlay for the full stack.

KMS upgrade: backup before recreating the container

Section titled “KMS upgrade: backup before recreating the container”

Do not pull/recreate the KMS before locating and backing up its database. The historical /root/cosmian-kms mount may not contain the actual SQLite files. The 5.12 container may have stored them only in its writable layer. Recover them from that still-existing container; a new empty volume does not recover CA keys.

  1. Stop gateways/controllers and backend writers. Record the deployed KMS image digest, container name, complete configuration, and mounts. Read the startup log’s actual main_db_params SQLite path. Depending on image/configuration, paths can be /cosmian-kms/sqlite-data, /var/lib/cosmian-kms/sqlite-data, or another configured path. Do not assume the historical mount was effective.

  2. Stop the KMS without removing its container. Make a protected, offline copy of the entire database directory, including WAL/SHM and all database files:

    Terminal window
    # Substitute the real container name and data path found above.
    set -eu
    kms_old_container=pki-kms
    kms_old_data_path=/actual/path/from/kms-startup-log
    kms_backup_dir=/secure/backups/kms-before-524
    test ! -e "$kms_backup_dir"
    mkdir -m 700 "$kms_backup_dir"
    docker stop "$kms_old_container"
    docker cp "$kms_old_container:$kms_old_data_path/." "$kms_backup_dir/"

    Keep the old container and original data untouched until the upgrade passes. Verify the backup contains the existing DB, not an empty directory. Retain the matching PKI backend database backup as well.

  3. Copy the backup into a new staging data directory/volume, preserving file ownership and permissions. Test 5.28 against that copy first. Do not point it at the only copy of your 5.12 DB. The full-stack Compose now maps ../kms/data to /cosmian-kms/sqlite-data, mounts ../kms/kms.toml at /etc/cosmian/kms.toml, and sets COSMIAN_KMS_CONF to that file, matching the configuration-file approach of kms/docker-compose.yml. For another data volume, adjust only the source side of the mount.

  4. kms.toml uses the 5.28 [db] database_type/sqlite_path fields with absolute paths, [http], and [workspace]. The old [database] type/path fields are ignored by the tested image. In config-file mode the TOML takes precedence over server/database environment settings; edit the TOML for another port.

  5. Confirm the new startup log names the mounted directory, verify existing CA certificate retrieval and issuance, and check RA Activate/Sign/Decrypt before resuming writers. Test that data survives container recreation against the staging volume. Live Intune/device acceptance remains separate.

  6. If checks fail, stop the new KMS and return to the recorded old image and untouched old data, not the staging copy. Coordinate backend rollback with its pre-upgrade DB backup. Never delete the old CA keys as a repair step.

Migration 0010 has its own backup/rollback runbook, docs/deployment/integrations-0010.md; the integration and KMS upgrades are separate operations.

Terminal window
# Backup database
docker-compose exec backend tar czf - /app/backend/data | \
gzip > backup-$(date +%Y%m%d).tar.gz
# Or back up the bind-mounted data directory (docker/../pki) with the stack stopped
tar czf db-backup.tar.gz -C ../pki .
Terminal window
# Restore from backup
# With the stack stopped
tar xzf db-backup.tar.gz -C ../pki

All services include health checks:

Terminal window
# Check overall health
docker-compose ps
# Test endpoints
curl http://localhost:3000/health # Backend
curl http://localhost:8080/health # Frontend
docker-compose exec backend wget -qO- http://kms:9998/health # KMS (not published to the host)
Terminal window
# Follow all logs
docker-compose logs -f
# Follow specific service
docker-compose logs -f backend
# Last 100 lines
docker-compose logs --tail=100
# Export logs
docker-compose logs > logs-$(date +%Y%m%d).txt

For issues or questions:

Complete OIDC templates for providers exposing roles through UserInfo are included:

  • backend/.env.oidc.example: backend development settings.
  • frontend/.env.oidc.example: frontend development settings, including groups scope.
  • docker/.env.oidc.example: Docker Compose backend settings.
  • docker/config.oidc.example.json: frontend runtime configuration for Docker.

For a new local development setup, run from the repository root:

Terminal window
cp -n backend/.env.oidc.example backend/.env
cp -n frontend/.env.oidc.example frontend/.env

For a new Docker setup, run from the repository root:

Terminal window
cp -n docker/.env.oidc.example docker/.env
cp -n docker/config.oidc.example.json docker/config.json

These commands preserve existing files. If configuration already exists, merge the OIDC settings into it instead. Replace id.example.com, REPLACE_WITH_OIDC_CLIENT_ID and REPLACE_WITH_ACCESS_TOKEN_AUDIENCE before starting. Set API and frontend URLs to your deployment’s browser-accessible URLs; the templates use local development ports. Actual .env files are local configuration and are not committed.

For Docker, .env configures the backend; the SPA separately reads docker/config.json, which Compose already mounts. Setting only VITE_OIDC_* in docker/.env does not configure frontend OIDC. After editing the files:

Terminal window
cd docker
docker compose up -d --force-recreate backend frontend

For local development, start/restart the stack using pnpm dev as documented in DEVELOPMENT.md (stop an existing session with pnpm dev:stop first).

Some OIDC providers, including Pocket ID v2.18.0, supply user groups through ID tokens and UserInfo rather than access-token role claims. These templates use groups as an example scope and role claim; adjust both to your provider. For providers embedding roles in access tokens, keep OIDC_ROLES_SOURCE=token. Enable the optional UserInfo role source on the backend:

OIDC_ISSUER=https://id.example.com
OIDC_AUDIENCE=<expected-access-token-audience>
OIDC_ROLES_SOURCE=userinfo
OIDC_ROLES_CLAIM=groups

Use the actual aud in the access token for OIDC_AUDIENCE; do not assume it is the client ID. Configure a public OIDC client with PKCE in your provider and assign the user to the group named exactly admin. Request openid profile email groups in VITE_OIDC_SCOPE (development) or oidc.scope in the frontend runtime config.json (Docker). Set the authority and client ID to your OIDC provider values. Register the frontend origin plus /callback and /silent-renew.html as callback URLs, and the origin plus / as the logout redirect if supported.

Recreate the backend container after changing its environment, restart the frontend development server after changing Vite variables, and sign in again to grant the groups scope. Do not put a client secret in the SPA.

The backend still verifies the access token’s signature, issuer and audience locally before sending it to the discovered UserInfo endpoint. That endpoint must share the discovered issuer’s origin and use HTTPS (HTTP is allowed only for loopback development). The backend needs outbound access to discovery, JWKS and UserInfo. Redirects from UserInfo are refused and each lookup times out after five seconds. A lookup failure or subject mismatch rejects authentication; missing groups grant no admin rights. Token roles are not used as a fallback.

UserInfo is queried on every authenticated request, without caching roles. Group changes therefore apply on the next request when the provider reflects them in UserInfo; this adds a provider request and makes authentication depend on its availability. The default OIDC_ROLES_SOURCE=token preserves existing JWT-based providers and M2M clients; enable UserInfo only for deployments whose tokens can access the provider’s UserInfo endpoint. The GUI currently has no admin-role badge.

Upgrade from cluster tokens to integration service tokens (migration 0010)

Section titled “Upgrade from cluster tokens to integration service tokens (migration 0010)”

Migration 0010 replaces clusters with integrations, preserving token hashes, CA bindings, usage and revocation state. Certificate ownership is backfilled in integration_id; legacy k8s_cluster_id values are retained. Only exclusively lowercase scep: request histories are reclassified as SCEP. Mixed/empty or uppercase histories remain Kubernetes. Legacy cluster.* calls and /clusters links remain compatible; new management uses integration.* and /integrations.

The backend entrypoint migrates automatically on start. Back up the SQLite database before pulling/starting the upgrade. Redeploying v3.14.x against the migrated database fails because that code expects clusters. Follow the 0010 backup and rollback runbook. Rollback restores the entire pre-upgrade database and discards later changes; it is not a reverse DDL migration. The gateway is deployed separately.

SCEP RA renewal with a retained key requires KMS 5.28.0: 5.24 derives the certificate serial from the public key and therefore reuses it on renewal. The backend refuses serial collisions. 5.28 generates fresh random serials. Do not treat 5.24 as a supported automatic RA-renewal deployment.