mirror of
https://github.com/KLogicHQ/nats-console.git
synced 2026-10-07 21:50:52 +00:00
218 lines
6.5 KiB
YAML
218 lines
6.5 KiB
YAML
# =============================================================================
|
|
# NATS Console - Production Docker Compose
|
|
# =============================================================================
|
|
# Production deployment with separate, scalable services.
|
|
#
|
|
# Usage:
|
|
# # With Docker named volume
|
|
# docker-compose -f docker-compose.prod.yml --env-file .env.prod up -d
|
|
#
|
|
# # With local data folder
|
|
# mkdir -p ./nats-console-data
|
|
# docker-compose -f docker-compose.prod.yml --env-file .env.prod up -d
|
|
#
|
|
# Data Structure (in single volume or ./nats-console-data):
|
|
# /data (or nats-console-data/)
|
|
# ├── postgres/ - PostgreSQL data
|
|
# ├── redis/ - Redis data
|
|
# ├── clickhouse/ - ClickHouse data
|
|
# └── nats/ - NATS JetStream data
|
|
# =============================================================================
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# =============================================================================
|
|
# Application Services
|
|
# =============================================================================
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/api/Dockerfile
|
|
image: nats-console/api:latest
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3001:3001"
|
|
environment:
|
|
- NODE_ENV=production
|
|
- PORT=3001
|
|
- DATABASE_URL=${DATABASE_URL:-postgresql://nats_console:nats_console@postgres:5432/nats_console}
|
|
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
|
|
- CLICKHOUSE_URL=${CLICKHOUSE_URL:-http://clickhouse:8123}
|
|
- CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-nats_console}
|
|
- NATS_URL=${NATS_URL:-nats://nats:4222}
|
|
- JWT_SECRET=${JWT_SECRET}
|
|
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-15m}
|
|
- JWT_REFRESH_EXPIRES_IN=${JWT_REFRESH_EXPIRES_IN:-7d}
|
|
- LOG_LEVEL=${LOG_LEVEL:-info}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
clickhouse:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
networks:
|
|
- nats-console
|
|
|
|
web:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/web/Dockerfile
|
|
image: nats-console/web:latest
|
|
restart: unless-stopped
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
- NODE_ENV=production
|
|
- NEXT_PUBLIC_API_URL=${API_URL:-http://localhost:3001/api/v1}
|
|
- NEXT_PUBLIC_WS_URL=${WS_URL:-ws://localhost:3001/ws}
|
|
depends_on:
|
|
- api
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 30s
|
|
networks:
|
|
- nats-console
|
|
|
|
workers:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/workers/Dockerfile
|
|
image: nats-console/workers:latest
|
|
restart: unless-stopped
|
|
environment:
|
|
- NODE_ENV=production
|
|
- DATABASE_URL=${DATABASE_URL:-postgresql://nats_console:nats_console@postgres:5432/nats_console}
|
|
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
|
|
- CLICKHOUSE_URL=${CLICKHOUSE_URL:-http://clickhouse:8123}
|
|
- CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:-nats_console}
|
|
- NATS_URL=${NATS_URL:-nats://nats:4222}
|
|
- LOG_LEVEL=${LOG_LEVEL:-info}
|
|
depends_on:
|
|
- api
|
|
- postgres
|
|
- redis
|
|
- clickhouse
|
|
networks:
|
|
- nats-console
|
|
|
|
# =============================================================================
|
|
# Database Services
|
|
# =============================================================================
|
|
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
volumes:
|
|
# Single data folder - postgres subdirectory
|
|
- ${DATA_DIR:-nats_console_data}:/data
|
|
environment:
|
|
- POSTGRES_USER=${POSTGRES_USER:-nats_console}
|
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nats_console}
|
|
- POSTGRES_DB=${POSTGRES_DB:-nats_console}
|
|
- PGDATA=/data/postgres
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nats_console} -d ${POSTGRES_DB:-nats_console}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- nats-console
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
restart: unless-stopped
|
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru --dir /data/redis
|
|
volumes:
|
|
# Single data folder - redis subdirectory
|
|
- ${DATA_DIR:-nats_console_data}:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- nats-console
|
|
|
|
clickhouse:
|
|
image: clickhouse/clickhouse-server:latest
|
|
restart: unless-stopped
|
|
volumes:
|
|
# Single data folder - clickhouse subdirectory
|
|
- ${DATA_DIR:-nats_console_data}:/data
|
|
- ./infrastructure/clickhouse/init:/docker-entrypoint-initdb.d
|
|
environment:
|
|
- CLICKHOUSE_DB=${CLICKHOUSE_DATABASE:-nats_console}
|
|
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
|
|
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-}
|
|
- CLICKHOUSE_DATA_DIR=/data/clickhouse
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- nats-console
|
|
|
|
nats:
|
|
image: nats:2.10-alpine
|
|
restart: unless-stopped
|
|
command: ["-js", "-m", "8222", "--store_dir", "/data/nats"]
|
|
ports:
|
|
- "4222:4222"
|
|
- "8222:8222"
|
|
volumes:
|
|
# Single data folder - nats subdirectory
|
|
- ${DATA_DIR:-nats_console_data}:/data
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- nats-console
|
|
|
|
# =============================================================================
|
|
# Reverse Proxy (Optional)
|
|
# =============================================================================
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./docker/nginx/ssl:/etc/nginx/ssl:ro
|
|
depends_on:
|
|
- web
|
|
- api
|
|
networks:
|
|
- nats-console
|
|
profiles:
|
|
- with-nginx
|
|
|
|
# =============================================================================
|
|
# Volumes
|
|
# =============================================================================
|
|
# Single volume for all data, with subdirectories for each service
|
|
volumes:
|
|
nats_console_data:
|
|
name: nats-console-data
|
|
|
|
networks:
|
|
nats-console:
|
|
driver: bridge
|