Skip to main content

Docker Compose Deployment

Idenplane provides production-ready Docker Compose configurations for easy deployment. This guide covers both production and development setups.


Quick Start​

The fastest way to deploy Idenplane with Docker Compose:

# Download the compose file and the helper that writes .env
curl --fail --location -o docker-compose.yml https://raw.githubusercontent.com/idenplane/idenplane/main/docker-compose.yml
curl --fail --location -o setup-env.cjs https://raw.githubusercontent.com/idenplane/idenplane/main/scripts/setup-env.cjs

# Generate .env with unique secrets (needs Node.js 24; never overwrites an existing file)
node setup-env.cjs

# Start the stack and wait until it is healthy
docker compose up -d --wait --wait-timeout 180

Production Deployment​

docker-compose.yml uses the pre-built Docker image and includes PostgreSQL. It binds to 127.0.0.1 only: put your own TLS-terminating reverse proxy in front of it, or use one of the TLS stacks below.

Configuration​

The compose file refuses to start unless .env (or the environment) sets these:

VariableHow to generate
POSTGRES_PASSWORDopenssl rand -hex 16
ADMIN_API_KEYopenssl rand -hex 32 (in production at least 32 characters, or the server exits)
ADMIN_PASSWORDopenssl rand -hex 16 (admin and placeholders are refused)
WEBHOOK_SECRET_KEYopenssl rand -hex 32
WEBHOOK_ENCRYPTION_SALTopenssl rand -hex 16

node scripts/setup-env.cjs writes all five. Also set BASE_URL to your public https:// origin. Optional: ADMIN_USER (default admin), THROTTLE_TTL, THROTTLE_LIMIT, and IDENPLANE_IMAGE to pin a release image such as islamawad/idenplane:0.10.1.

warning

Keep .env private and back it up. Changing WEBHOOK_SECRET_KEY or WEBHOOK_ENCRYPTION_SALT later makes stored secrets unreadable.

docker-compose.yml​

services:
# Redis is optional. Uncomment the `redis` service and the REDIS_URL env var
# on the `app` service to enable the Redis cache/session layer.
# redis:
# image: redis:7-alpine
# command: ["redis-server", "--save", "", "--appendonly", "no"]
# ports:
# - "6379:6379"
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 5s
# timeout: 3s
# retries: 5

db:
image: postgres:16-alpine
environment:
POSTGRES_USER: idenplane
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run node scripts/setup-env.cjs first}
POSTGRES_DB: idenplane
ports:
- "127.0.0.1:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U idenplane"]
interval: 5s
timeout: 3s
retries: 5

app:
image: ${IDENPLANE_IMAGE:-islamawad/idenplane:latest}
ports:
- "127.0.0.1:3000:3000"
environment:
DATABASE_URL: postgresql://idenplane:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}@db:5432/idenplane
PORT: "3000"
NODE_ENV: production
ADMIN_API_KEY: ${ADMIN_API_KEY:?Set ADMIN_API_KEY}
ADMIN_USER: ${ADMIN_USER:-admin}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:?Set ADMIN_PASSWORD}
# Required: the server hard-exits in production when these are unset, so
# fail fast here with a clear message instead of an opaque restart loop.
WEBHOOK_SECRET_KEY: ${WEBHOOK_SECRET_KEY:?Set WEBHOOK_SECRET_KEY (openssl rand -hex 32)}
WEBHOOK_ENCRYPTION_SALT: ${WEBHOOK_ENCRYPTION_SALT:?Set WEBHOOK_ENCRYPTION_SALT (openssl rand -hex 16)}
THROTTLE_TTL: ${THROTTLE_TTL:-60000}
THROTTLE_LIMIT: ${THROTTLE_LIMIT:-100}
BASE_URL: ${BASE_URL:-http://localhost:3000}
# Where the upgrade flow writes pre-migration backups. Points at the
# `backups` volume below so a dump survives the container being replaced —
# a backup on the container filesystem is not a backup.
BACKUP_DIR: /var/lib/idenplane/backups
# Uncomment to enable Redis cache (requires the redis service above):
# REDIS_URL: redis://redis:6379
# SESSION_STORE: ${SESSION_STORE:-database}
volumes:
- backups:/var/lib/idenplane/backups
depends_on:
db:
condition: service_healthy
# Uncomment when enabling redis:
# redis:
# condition: service_healthy
restart: unless-stopped

volumes:
pgdata:
backups:

Starting the Stack​

# Pull the latest image and start
docker compose pull
docker compose up -d

# Check status
docker compose ps

# View logs
docker compose logs -f app

Verifying the Deployment​

EndpointDescription
http://localhost:3000/health/liveLiveness check
http://localhost:3000/health/readyReadiness check
http://localhost:3000/consoleAdmin Console
http://localhost:3000/apiSwagger API Docs

Unattended setup​

To bring an instance up fully configured, with no one opening the setup wizard, mount a bootstrap document and set BOOTSTRAP_FILE, or pass the document itself in BOOTSTRAP_JSON. At the first start, the declared realms, clients and SMTP settings are created and the wizard is closed, in one transaction:

app:
environment:
BOOTSTRAP_FILE: /etc/idenplane/bootstrap.json
ACME_WEB_CLIENT_SECRET: ${ACME_WEB_CLIENT_SECRET:?} # referenced as ${env:ACME_WEB_CLIENT_SECRET}
volumes:
- ./bootstrap.json:/etc/idenplane/bootstrap.json:ro

If bootstrap fails, the container exits before it is ever healthy and nothing is written. Unattended Bootstrap has the document format, a complete compose file for a VM, and how restarts and multiple instances behave.

Production with TLS (Traefik + Redis)​

The example above expects you to put your own TLS-terminating reverse proxy in front of it. If you'd rather have a complete, ready-to-run stack — automatic Let's Encrypt certificates via Traefik, plus Redis for the cache/session layer — use docker-compose.production.yml from the repo root instead.

This requires a real domain name already pointed at the host, since Traefik's ACME TLS challenge must be reachable on port 443 from the public internet.

DOMAIN=auth.example.com \
ACME_EMAIL=you@example.com \
POSTGRES_PASSWORD=$(openssl rand -hex 16) \
ADMIN_API_KEY=$(openssl rand -hex 32) \
ADMIN_PASSWORD=$(openssl rand -hex 16) \
WEBHOOK_SECRET_KEY=$(openssl rand -hex 32) \
WEBHOOK_ENCRYPTION_SALT=$(openssl rand -hex 16) \
docker compose -f docker-compose.production.yml up -d

What it sets up beyond the basic production example:

  • Traefik terminates TLS on :443 (redirecting :80 to it) and requests/renews a Let's Encrypt certificate for $DOMAIN automatically — no manual certbot steps.
  • Redis is enabled out of the box (REDIS_URL, SESSION_STORE=redis are already set on the app service — you don't need to uncomment anything).
  • db and redis have no published ports — only the app and traefik containers can reach them, reducing the attack surface versus the basic example's 127.0.0.1:5432 binding.
  • TRUSTED_PROXIES=* is set on app since Traefik is the only thing that can reach it directly within the compose network — safe here, but don't copy this value into a setup where the app is also directly reachable from elsewhere.

Production with TLS (Nginx + Redis)​

Prefer Nginx over Traefik? docker-compose.nginx.yml sets up the same stack — Postgres, Redis, automatic Let's Encrypt TLS — using nginx-proxy and its acme-companion instead. They watch the Docker socket and generate Nginx's vhost config and certificates automatically from labels on the app service — there's no Nginx config file to hand-write or certbot cron job to set up.

This also requires a real domain name already pointed at the host, since the ACME HTTP-01 challenge must be reachable on port 80 from the public internet.

DOMAIN=auth.example.com \
ACME_EMAIL=you@example.com \
POSTGRES_PASSWORD=$(openssl rand -hex 16) \
ADMIN_API_KEY=$(openssl rand -hex 32) \
ADMIN_PASSWORD=$(openssl rand -hex 16) \
WEBHOOK_SECRET_KEY=$(openssl rand -hex 32) \
WEBHOOK_ENCRYPTION_SALT=$(openssl rand -hex 16) \
docker compose -f docker-compose.nginx.yml up -d

What it sets up, same as the Traefik version above:

  • nginx-proxy terminates TLS on :443 and reverse-proxies to app based on the VIRTUAL_HOST/VIRTUAL_PORT labels set on it — no vhost file to write by hand.
  • acme-companion requests and renews the Let's Encrypt certificate for $DOMAIN automatically, triggered by the LETSENCRYPT_HOST label.
  • Redis is enabled out of the box, same as the Traefik template.
  • db and redis have no published ports; TRUSTED_PROXIES=* is set on app for the same reason as the Traefik version — nginx-proxy is the only thing that can reach it directly within the compose network.

Development Deployment​

docker-compose.dev.yml runs your checkout with hot reload: the source tree is mounted into the container and nest start --watch rebuilds and restarts on every change. It uses the image's build stage (dependencies, Prisma client, toolchain) and keeps the image's node_modules. The API is on http://localhost:3000, and the app and database listen on 127.0.0.1 only. The admin console is not built in this mode: run it from admin-ui/ with npm run dev. To run Node on your machine instead, start only the database with docker compose -f docker-compose.dev.yml up -d db and run npm run start:dev.

docker-compose.dev.yml​

# Local development: the source tree mounted into the container, rebuilt and
# restarted on every change (`nest start --watch`). Not for production: the
# database password is fixed, and nothing here is hardened.
#
# docker compose -f docker-compose.dev.yml up --build
#
# The API, OIDC endpoints and Swagger are on http://localhost:3000. The admin
# console is not built in this mode; run it with hot reload from admin-ui/
# (`npm install && npm run dev`, http://localhost:5173), or use
# docker-compose.yml for the built image with the console at /console/.
services:
# ── Redis (optional) ──────────────────────────────────────────────────────
# Uncomment to enable the Redis cache/session layer.
# redis:
# image: redis:7-alpine
# command: ["redis-server", "--save", "", "--appendonly", "no"]
# ports:
# - "127.0.0.1:6379:6379"
# healthcheck:
# test: ["CMD", "redis-cli", "ping"]
# interval: 5s
# timeout: 3s
# retries: 5

# ── PostgreSQL (the supported database) ───────────────────────────────────
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: idenplane
# A development-only password; the database is reachable from this
# machine only.
POSTGRES_PASSWORD: idenplane
POSTGRES_DB: idenplane
ports:
- "127.0.0.1:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U idenplane"]
interval: 5s
timeout: 3s
retries: 5

app:
# The image's build stage: dependencies, the generated Prisma client and
# the toolchain, without the production stage's entrypoint. The source
# comes from the bind mount below, so the dist/ the image built is not
# used: `nest start --watch` compiles the mounted source itself.
build:
context: .
target: build
command: ["sh", "-c", "npx prisma migrate deploy && npx prisma generate && npm run start:dev"]
ports:
- "127.0.0.1:3000:3000"
volumes:
- .:/app
# Keep the image's dependencies: the host's node_modules (if any) are
# for the host's platform, and an empty one would hide them.
- /app/node_modules
- /app/admin-ui/node_modules
environment:
DATABASE_URL: postgresql://idenplane:idenplane@db:5432/idenplane
PORT: "3000"
NODE_ENV: development
ADMIN_API_KEY: ${ADMIN_API_KEY:-dev-api-key-do-not-use-in-production}
ADMIN_USER: ${ADMIN_USER:-admin}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-dev-admin-password}
THROTTLE_TTL: ${THROTTLE_TTL:-60000}
THROTTLE_LIMIT: ${THROTTLE_LIMIT:-100}
BASE_URL: ${BASE_URL:-http://localhost:3000}
# Uncomment to enable Redis cache (requires the redis service above):
# REDIS_URL: redis://redis:6379
# SESSION_STORE: ${SESSION_STORE:-database}
depends_on:
db:
condition: service_healthy
restart: unless-stopped

volumes:
pgdata:

Starting Development Stack​

# Use the dev compose file (rebuilds the build stage when the Dockerfile or dependencies change)
docker compose -f docker-compose.dev.yml up -d --build

# View logs
docker compose -f docker-compose.dev.yml logs -f

Database​

Idenplane runs on PostgreSQL 16 or later, and only on PostgreSQL. The compose files start the official postgres image:

db:
image: postgres:16-alpine
environment:
POSTGRES_USER: idenplane
POSTGRES_PASSWORD: idenplane
POSTGRES_DB: idenplane

To use a managed database instead (Amazon RDS or Aurora PostgreSQL, Google Cloud SQL, Azure Database for PostgreSQL, Supabase, Neon), remove the db service and point DATABASE_URL at it. Use TLS with certificate verification, as the Production Checklist describes.


Optional: Redis Cache​

Redis is optional and can be enabled for session caching:

  1. Uncomment the Redis service in your compose file

  2. Uncomment the REDIS_URL and SESSION_STORE environment variables:

    REDIS_URL: redis://redis:6379
    SESSION_STORE: ${SESSION_STORE:-database}
  3. Uncomment the Redis health check dependency:

    depends_on:
    db:
    condition: service_healthy
    redis:
    condition: service_healthy

Common Tasks​

Updating Idenplane​

# Pull the latest image
docker compose pull

# Restart with new image
docker compose up -d

Backing Up Data​

# Backup PostgreSQL data
docker compose exec db pg_dump -U idenplane idenplane > backup.sql

# Restore from backup
docker compose exec -T db psql -U idenplane idenplane < backup.sql

Viewing Logs​

# All services
docker compose logs -f

# Specific service
docker compose logs -f app
docker compose logs -f db

Stopping the Stack​

# Stop services (preserves data)
docker compose stop

# Stop and remove containers
docker compose down

# Stop and remove volumes (deletes data!)
docker compose down -v

Troubleshooting​

Container Won't Start​

  1. Check logs: docker compose logs app
  2. Verify DATABASE_URL is correct
  3. Ensure database is healthy before app starts

Database Connection Errors​

  1. Verify PostgreSQL is running: docker compose ps db
  2. Check health status: docker compose exec db pg_isready -U idenplane
  3. Inspect connection string in .env

Permission Denied Errors​

If you see permission errors on volumes:

# Reset volume permissions
docker compose down
docker volume rm $(docker volume ls -q | grep idenplane)
docker compose up -d

Next Steps​

Kubernetes Deploy Idenplane on Kubernetes with Helm charts

Environment Variables Complete list of all configuration options

Configuration Detailed configuration guide


idenplane.com · GitHub · Discord