Files

406 lines
11 KiB
YAML

# Lux MPC/KMS Infrastructure
# Full deployment stack for bridge.lux.network
#
# Services:
# - lux-mpc-{0,1,2}: MPC signing nodes
# - lux-kms: Key management service
# - nats: Message broker for MPC coordination
# - consul: Service discovery and config
# - minio: S3-compatible backup storage (Hanzo Storage)
# - postgres: KMS database
# - vault: Secrets management (optional, for HSM integration)
services:
# ============================================================
# INFRASTRUCTURE
# ============================================================
nats:
image: nats:2.10-alpine
container_name: lux-nats
ports:
- "4222:4222"
- "8222:8222" # Monitoring
command: "-js -m 8222 --store_dir /data"
volumes:
- nats-data:/data
networks:
- lux-network
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "4222"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
consul:
image: hashicorp/consul:1.18
container_name: lux-consul
ports:
- "8500:8500"
- "8600:8600/udp"
command: "agent -server -bootstrap-expect=1 -ui -client=0.0.0.0"
volumes:
- consul-data:/consul/data
networks:
- lux-network
environment:
- CONSUL_BIND_INTERFACE=eth0
healthcheck:
test: ["CMD", "consul", "members"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
# MinIO - S3-compatible storage for backups (Hanzo Storage)
minio:
image: minio/minio:latest
container_name: lux-minio
ports:
- "9000:9000"
- "9001:9001" # Console
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER:-luxadmin}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-luxsecret123}
command: server /data --console-address ":9001"
volumes:
- minio-data:/data
networks:
- lux-network
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
# Create backup bucket
minio-init:
image: minio/mc:latest
container_name: lux-minio-init
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
mc alias set myminio http://minio:9000 $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD};
mc mb myminio/mpc-backups --ignore-existing;
mc mb myminio/kms-backups --ignore-existing;
mc mb myminio/bridge-data --ignore-existing;
mc version enable myminio/mpc-backups;
mc ilm import myminio/mpc-backups < /policies/backup-lifecycle.json || true;
exit 0;
"
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER:-luxadmin}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-luxsecret123}
volumes:
- ./config/minio:/policies:ro
networks:
- lux-network
postgres:
image: postgres:16-alpine
container_name: lux-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER:-lux}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-luxsecret}
- POSTGRES_DB=${POSTGRES_DB:-luxkms}
volumes:
- postgres-data:/var/lib/postgresql/data
- ./config/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks:
- lux-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U lux"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
# ============================================================
# MPC NODES (3-of-5 threshold for production)
# ============================================================
lux-mpc-0:
image: ghcr.io/luxfi/mpc:latest
container_name: lux-mpc-0
ports:
- "6000:6000"
- "9090:9090" # gRPC
environment:
- NODE_ID=mpc-node-0
- NODE_PORT=6000
- GRPC_PORT=9090
- NATS_URL=nats://nats:4222
- CONSUL_URL=http://consul:8500
- DATA_DIR=/data/mpc
- LOG_LEVEL=${LOG_LEVEL:-info}
- BACKUP_ENABLED=true
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=mpc-backups
- S3_ACCESS_KEY=${MINIO_ROOT_USER:-luxadmin}
- S3_SECRET_KEY=${MINIO_ROOT_PASSWORD:-luxsecret123}
- S3_REGION=us-east-1
- BACKUP_INTERVAL=3600 # 1 hour
- BACKUP_RETENTION=604800 # 7 days
- BADGER_ENCRYPTION_KEY=${BADGER_KEY_0:-}
volumes:
- mpc-data-0:/data/mpc
- ./config/mpc/node-0:/config:ro
networks:
- lux-network
depends_on:
nats:
condition: service_healthy
consul:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:6000/health"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
lux-mpc-1:
image: ghcr.io/luxfi/mpc:latest
container_name: lux-mpc-1
ports:
- "6001:6000"
- "9091:9090"
environment:
- NODE_ID=mpc-node-1
- NODE_PORT=6000
- GRPC_PORT=9090
- NATS_URL=nats://nats:4222
- CONSUL_URL=http://consul:8500
- DATA_DIR=/data/mpc
- LOG_LEVEL=${LOG_LEVEL:-info}
- BACKUP_ENABLED=true
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=mpc-backups
- S3_ACCESS_KEY=${MINIO_ROOT_USER:-luxadmin}
- S3_SECRET_KEY=${MINIO_ROOT_PASSWORD:-luxsecret123}
- S3_REGION=us-east-1
- BACKUP_INTERVAL=3600
- BACKUP_RETENTION=604800
- BADGER_ENCRYPTION_KEY=${BADGER_KEY_1:-}
volumes:
- mpc-data-1:/data/mpc
- ./config/mpc/node-1:/config:ro
networks:
- lux-network
depends_on:
nats:
condition: service_healthy
consul:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:6000/health"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
lux-mpc-2:
image: ghcr.io/luxfi/mpc:latest
container_name: lux-mpc-2
ports:
- "6002:6000"
- "9092:9090"
environment:
- NODE_ID=mpc-node-2
- NODE_PORT=6000
- GRPC_PORT=9090
- NATS_URL=nats://nats:4222
- CONSUL_URL=http://consul:8500
- DATA_DIR=/data/mpc
- LOG_LEVEL=${LOG_LEVEL:-info}
- BACKUP_ENABLED=true
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=mpc-backups
- S3_ACCESS_KEY=${MINIO_ROOT_USER:-luxadmin}
- S3_SECRET_KEY=${MINIO_ROOT_PASSWORD:-luxsecret123}
- S3_REGION=us-east-1
- BACKUP_INTERVAL=3600
- BACKUP_RETENTION=604800
- BADGER_ENCRYPTION_KEY=${BADGER_KEY_2:-}
volumes:
- mpc-data-2:/data/mpc
- ./config/mpc/node-2:/config:ro
networks:
- lux-network
depends_on:
nats:
condition: service_healthy
consul:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:6000/health"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
# ============================================================
# LUX KMS
# ============================================================
lux-kms:
image: ghcr.io/luxfi/kms:latest
container_name: lux-kms
ports:
- "8080:8080"
environment:
- NODE_ENV=production
- PORT=8080
- DATABASE_URL=postgresql://${POSTGRES_USER:-lux}:${POSTGRES_PASSWORD:-luxsecret}@postgres:5432/${POSTGRES_DB:-luxkms}
- REDIS_URL=redis://redis:6379
- NATS_URL=nats://nats:4222
- CONSUL_URL=http://consul:8500
# MPC Configuration
- MPC_NODES=mpc-node-0:6000,mpc-node-1:6001,mpc-node-2:6002
- MPC_THRESHOLD=2
- MPC_TOTAL_NODES=3
# S3 Backup
- S3_ENDPOINT=http://minio:9000
- S3_BUCKET=kms-backups
- S3_ACCESS_KEY=${MINIO_ROOT_USER:-luxadmin}
- S3_SECRET_KEY=${MINIO_ROOT_PASSWORD:-luxsecret123}
# Auth
- JWT_SECRET=${JWT_SECRET:-change-me-in-production}
- ENCRYPTION_KEY=${KMS_ENCRYPTION_KEY:-}
volumes:
- kms-data:/app/data
- ./config/kms:/app/config:ro
networks:
- lux-network
depends_on:
postgres:
condition: service_healthy
nats:
condition: service_healthy
consul:
condition: service_healthy
lux-mpc-0:
condition: service_healthy
lux-mpc-1:
condition: service_healthy
lux-mpc-2:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
# Redis for KMS caching and sessions
redis:
image: redis:7-alpine
container_name: lux-redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- lux-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
# ============================================================
# MONITORING (Optional)
# ============================================================
prometheus:
image: prom/prometheus:latest
container_name: lux-prometheus
ports:
- "9093:9090"
volumes:
- ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
networks:
- lux-network
profiles:
- monitoring
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: lux-grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
volumes:
- grafana-data:/var/lib/grafana
- ./config/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/datasources:/etc/grafana/provisioning/datasources:ro
networks:
- lux-network
profiles:
- monitoring
depends_on:
- prometheus
restart: unless-stopped
# ============================================================
# VOLUMES
# ============================================================
volumes:
nats-data:
consul-data:
minio-data:
postgres-data:
mpc-data-0:
mpc-data-1:
mpc-data-2:
kms-data:
redis-data:
prometheus-data:
grafana-data:
# ============================================================
# NETWORKS
# ============================================================
networks:
lux-network:
driver: bridge
ipam:
config:
- subnet: 172.30.0.0/16