refactor: unify docker-compose configs to use shared infrastructure
All microservices now use the shared rwa-network and connect to: - rwa-postgres: Shared PostgreSQL database server - rwa-redis: Shared Redis cache - rwa-kafka: Shared Kafka message broker Each service's docker-compose.yml now only defines the application container and uses `networks: external: true` to connect to the shared infrastructure defined in the root docker-compose.yml. This prevents duplicate infrastructure containers and ensures all services can communicate via Kafka and share the same Redis/PostgreSQL. Services updated: - admin-service - backup-service - blockchain-service - identity-service - leaderboard-service - mpc-service - presence-service 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ce281b0657
commit
6451cd6fc3
|
|
@ -1,8 +1,11 @@
|
|||
# =============================================================================
|
||||
# Admin Service - Docker Compose Configuration
|
||||
# Admin Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# 用途: 本地开发和独立部署 admin-service
|
||||
# 启动: docker compose up -d
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
|
|
@ -16,24 +19,21 @@ services:
|
|||
- NODE_ENV=production
|
||||
- APP_PORT=3010
|
||||
- API_PREFIX=api/v1
|
||||
# Database
|
||||
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_admin?schema=public
|
||||
# Database (shared PostgreSQL)
|
||||
- DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_admin?schema=public
|
||||
# JWT
|
||||
- JWT_SECRET=your-admin-jwt-secret-change-in-production
|
||||
- JWT_SECRET=${JWT_SECRET:-your-admin-jwt-secret-change-in-production}
|
||||
- JWT_EXPIRES_IN=7d
|
||||
# Redis (可选)
|
||||
- REDIS_HOST=redis
|
||||
# Redis (shared)
|
||||
- REDIS_HOST=rwa-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
||||
- REDIS_DB=9
|
||||
# File Storage
|
||||
- UPLOAD_DIR=/app/uploads
|
||||
- BASE_URL=${BASE_URL:-https://rwaapi.szaiai.com/api/v1}
|
||||
volumes:
|
||||
- uploads_data:/app/uploads
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3010/api/v1/health"]
|
||||
interval: 30s
|
||||
|
|
@ -42,55 +42,12 @@ services:
|
|||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- admin-network
|
||||
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: rwa-admin-postgres
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=rwa_admin
|
||||
ports:
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres -d rwa_admin"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- admin-network
|
||||
|
||||
# Redis (可选,用于缓存)
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: rwa-admin-redis
|
||||
ports:
|
||||
- "6380:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- admin-network
|
||||
- rwa-network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
name: admin-service-postgres-data
|
||||
redis_data:
|
||||
name: admin-service-redis-data
|
||||
uploads_data:
|
||||
name: admin-service-uploads-data
|
||||
|
||||
networks:
|
||||
admin-network:
|
||||
name: admin-service-network
|
||||
driver: bridge
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,53 +1,47 @@
|
|||
version: '3.8'
|
||||
# =============================================================================
|
||||
# Backup Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
backup-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: backup-service
|
||||
container_name: rwa-backup-service
|
||||
ports:
|
||||
- "${APP_PORT:-3002}:3002"
|
||||
- "3002:3002"
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:password@backup-db:5432/rwa_backup?schema=public
|
||||
# Application
|
||||
- NODE_ENV=production
|
||||
- APP_PORT=3002
|
||||
- APP_ENV=development
|
||||
- SERVICE_JWT_SECRET=${SERVICE_JWT_SECRET}
|
||||
- APP_ENV=production
|
||||
# Database (shared PostgreSQL)
|
||||
- DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_backup?schema=public
|
||||
# Service Authentication
|
||||
- SERVICE_JWT_SECRET=${SERVICE_JWT_SECRET:-your-service-jwt-secret}
|
||||
- ALLOWED_SERVICES=identity-service,recovery-service
|
||||
- BACKUP_ENCRYPTION_KEY=${BACKUP_ENCRYPTION_KEY}
|
||||
# Backup Encryption
|
||||
- BACKUP_ENCRYPTION_KEY=${BACKUP_ENCRYPTION_KEY:-0123456789abcdef0123456789abcdef}
|
||||
- BACKUP_ENCRYPTION_KEY_ID=${BACKUP_ENCRYPTION_KEY_ID:-key-v1}
|
||||
# Rate Limits
|
||||
- MAX_RETRIEVE_PER_DAY=3
|
||||
- MAX_STORE_PER_MINUTE=10
|
||||
depends_on:
|
||||
backup-db:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- backup-network
|
||||
restart: unless-stopped
|
||||
|
||||
backup-db:
|
||||
image: postgres:15-alpine
|
||||
container_name: backup-db
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_DB: rwa_backup
|
||||
volumes:
|
||||
- backup-db-data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5433:5432" # Different port to avoid conflict with main db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- backup-network
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3002/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
backup-db-data:
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
networks:
|
||||
backup-network:
|
||||
driver: bridge
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,82 +1,49 @@
|
|||
version: '3.8'
|
||||
# =============================================================================
|
||||
# Blockchain Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
blockchain-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: blockchain-service
|
||||
container_name: rwa-blockchain-service
|
||||
ports:
|
||||
- "3012:3012"
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- PORT=3012
|
||||
- DATABASE_URL=postgresql://rwa:rwa_password@postgres:5432/rwa_blockchain?schema=public
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_DB=11
|
||||
- KAFKA_BROKERS=kafka:9092
|
||||
- KAFKA_CLIENT_ID=blockchain-service
|
||||
- KAFKA_GROUP_ID=blockchain-service-group
|
||||
- KAVA_RPC_URL=https://evm.kava.io
|
||||
- BSC_RPC_URL=https://bsc-dataseed.binance.org
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
- kafka
|
||||
networks:
|
||||
- rwa-network
|
||||
# Application
|
||||
NODE_ENV: production
|
||||
APP_PORT: 3012
|
||||
API_PREFIX: api/v1
|
||||
# Database (shared PostgreSQL)
|
||||
DATABASE_URL: postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_blockchain?schema=public
|
||||
# Redis (shared)
|
||||
REDIS_HOST: rwa-redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_DB: 11
|
||||
# Kafka (shared)
|
||||
KAFKA_BROKERS: rwa-kafka:29092
|
||||
KAFKA_CLIENT_ID: blockchain-service
|
||||
KAFKA_GROUP_ID: blockchain-service-group
|
||||
# Blockchain RPC
|
||||
KAVA_RPC_URL: https://evm.kava.io
|
||||
BSC_RPC_URL: https://bsc-dataseed.binance.org
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3012/api/v1/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: blockchain-postgres
|
||||
environment:
|
||||
- POSTGRES_USER=rwa
|
||||
- POSTGRES_PASSWORD=rwa_password
|
||||
- POSTGRES_DB=rwa_blockchain
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: blockchain-redis
|
||||
command: redis-server --appendonly yes
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
ports:
|
||||
- "6379:6379"
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
kafka:
|
||||
image: bitnami/kafka:3.6
|
||||
container_name: blockchain-kafka
|
||||
environment:
|
||||
- KAFKA_CFG_NODE_ID=0
|
||||
- KAFKA_CFG_PROCESS_ROLES=controller,broker
|
||||
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
|
||||
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
|
||||
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
|
||||
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
||||
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
|
||||
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT
|
||||
volumes:
|
||||
- kafka-data:/bitnami/kafka
|
||||
ports:
|
||||
- "9092:9092"
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
networks:
|
||||
rwa-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
redis-data:
|
||||
kafka-data:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,121 +1,62 @@
|
|||
# =============================================================================
|
||||
# Identity Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
identity-service:
|
||||
build: .
|
||||
container_name: rwa-identity-service
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
# Application
|
||||
- NODE_ENV=production
|
||||
- APP_PORT=3000
|
||||
- APP_ENV=production
|
||||
# Database
|
||||
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_identity?schema=public
|
||||
# Database (shared PostgreSQL)
|
||||
- DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_identity?schema=public
|
||||
# JWT
|
||||
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
||||
- JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
|
||||
- JWT_ACCESS_EXPIRES_IN=2h
|
||||
- JWT_REFRESH_EXPIRES_IN=30d
|
||||
# Redis
|
||||
- REDIS_HOST=redis
|
||||
# Redis (shared)
|
||||
- REDIS_HOST=rwa-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
||||
- REDIS_DB=0
|
||||
# Kafka
|
||||
- KAFKA_BROKERS=kafka:29092
|
||||
# Kafka (shared)
|
||||
- KAFKA_BROKERS=rwa-kafka:29092
|
||||
- KAFKA_CLIENT_ID=identity-service
|
||||
- KAFKA_GROUP_ID=identity-service-group
|
||||
# Wallet Encryption
|
||||
- WALLET_ENCRYPTION_SALT=rwa-wallet-salt-change-in-production
|
||||
- WALLET_ENCRYPTION_SALT=${WALLET_ENCRYPTION_SALT:-rwa-wallet-salt-change-in-production}
|
||||
# MPC Service
|
||||
- MPC_SERVICE_URL=http://mpc-service:3001
|
||||
- MPC_SERVICE_URL=http://rwa-mpc-service:3006
|
||||
- MPC_MODE=remote
|
||||
- MPC_USE_EVENT_DRIVEN=true
|
||||
# Blockchain Service
|
||||
- BLOCKCHAIN_SERVICE_URL=http://rwa-blockchain-service:3012
|
||||
# Backup Service
|
||||
- BACKUP_SERVICE_URL=http://backup-service:3002
|
||||
- BACKUP_SERVICE_ENABLED=false
|
||||
- SERVICE_JWT_SECRET=your-service-jwt-secret-change-in-production
|
||||
- BACKUP_SERVICE_URL=http://rwa-backup-service:3002
|
||||
- BACKUP_SERVICE_ENABLED=true
|
||||
- SERVICE_JWT_SECRET=${SERVICE_JWT_SECRET:-your-service-jwt-secret-change-in-production}
|
||||
# Blockchain RPC
|
||||
- KAVA_RPC_URL=https://evm.kava.io
|
||||
- BSC_RPC_URL=https://bsc-dataseed.binance.org
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/health"]
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=rwa_identity
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
|
||||
zookeeper:
|
||||
image: confluentinc/cp-zookeeper:7.5.0
|
||||
environment:
|
||||
ZOOKEEPER_CLIENT_PORT: 2181
|
||||
ZOOKEEPER_TICK_TIME: 2000
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "2181"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
|
||||
kafka:
|
||||
image: confluentinc/cp-kafka:7.5.0
|
||||
depends_on:
|
||||
zookeeper:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "9092:9092"
|
||||
environment:
|
||||
KAFKA_BROKER_ID: 1
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://kafka:29092
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
|
||||
healthcheck:
|
||||
test: ["CMD", "kafka-topics", "--bootstrap-server", "localhost:9092", "--list"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
networks:
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,91 +1,52 @@
|
|||
version: '3.8'
|
||||
# =============================================================================
|
||||
# Leaderboard Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
# PostgreSQL database
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: leaderboard-postgres
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: leaderboard_db
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# Redis cache
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: leaderboard-redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# Kafka message broker
|
||||
zookeeper:
|
||||
image: confluentinc/cp-zookeeper:7.5.0
|
||||
container_name: leaderboard-zookeeper
|
||||
environment:
|
||||
ZOOKEEPER_CLIENT_PORT: 2181
|
||||
ZOOKEEPER_TICK_TIME: 2000
|
||||
|
||||
kafka:
|
||||
image: confluentinc/cp-kafka:7.5.0
|
||||
container_name: leaderboard-kafka
|
||||
depends_on:
|
||||
- zookeeper
|
||||
ports:
|
||||
- "9092:9092"
|
||||
environment:
|
||||
KAFKA_BROKER_ID: 1
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
healthcheck:
|
||||
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
# Application service
|
||||
app:
|
||||
leaderboard-service:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
target: production
|
||||
container_name: leaderboard-app
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
container_name: rwa-leaderboard-service
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "3007:3007"
|
||||
environment:
|
||||
# Application
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/leaderboard_db
|
||||
REDIS_HOST: redis
|
||||
APP_PORT: 3007
|
||||
# Database (shared PostgreSQL)
|
||||
DATABASE_URL: postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_leaderboard?schema=public
|
||||
# Redis (shared)
|
||||
REDIS_HOST: rwa-redis
|
||||
REDIS_PORT: 6379
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
JWT_SECRET: your-jwt-secret-for-docker
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
REDIS_DB: 6
|
||||
# Kafka (shared)
|
||||
KAFKA_BROKERS: rwa-kafka:29092
|
||||
KAFKA_CLIENT_ID: leaderboard-service
|
||||
KAFKA_GROUP_ID: leaderboard-service-group
|
||||
# JWT
|
||||
JWT_SECRET: ${JWT_SECRET:-your-jwt-secret-for-docker}
|
||||
JWT_EXPIRES_IN: 7d
|
||||
PORT: 3000
|
||||
command: >
|
||||
sh -c "npx prisma migrate deploy && node dist/main"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3007/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
networks:
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
# =============================================================================
|
||||
# MPC Service - Docker Compose
|
||||
# MPC Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
|
|
@ -9,32 +15,34 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: rwa-mpc-service
|
||||
ports:
|
||||
- "3001:3001"
|
||||
- "3006:3006"
|
||||
environment:
|
||||
# Application
|
||||
NODE_ENV: production
|
||||
APP_PORT: 3001
|
||||
APP_PORT: 3006
|
||||
API_PREFIX: api/v1
|
||||
# Database (PostgreSQL)
|
||||
DATABASE_URL: postgresql://postgres:password@postgres:5432/rwa_mpc?schema=public
|
||||
# Redis
|
||||
REDIS_HOST: redis
|
||||
# Database (shared PostgreSQL)
|
||||
DATABASE_URL: postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_mpc?schema=public
|
||||
# Redis (shared)
|
||||
REDIS_HOST: rwa-redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ""
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
REDIS_DB: 5
|
||||
# JWT
|
||||
JWT_SECRET: ${JWT_SECRET:-your-jwt-secret-change-in-production}
|
||||
JWT_ACCESS_EXPIRES_IN: 2h
|
||||
JWT_REFRESH_EXPIRES_IN: 30d
|
||||
# Kafka
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
# Kafka (shared)
|
||||
KAFKA_BROKERS: rwa-kafka:29092
|
||||
KAFKA_CLIENT_ID: mpc-service
|
||||
KAFKA_GROUP_ID: mpc-service-group
|
||||
# MPC System (Go/TSS Backend)
|
||||
MPC_SYSTEM_URL: ${MPC_SYSTEM_URL:-http://mpc-system:4000}
|
||||
MPC_API_KEY: ${MPC_API_KEY:-your-mpc-api-key}
|
||||
MPC_COORDINATOR_URL: ${MPC_COORDINATOR_URL:-http://mpc-system:8081}
|
||||
MPC_MESSAGE_ROUTER_WS_URL: ${MPC_MESSAGE_ROUTER_WS_URL:-ws://mpc-system:8082}
|
||||
# MPC System (Go/TSS Backend - deployed on 192.168.1.111)
|
||||
MPC_ACCOUNT_SERVICE_URL: ${MPC_ACCOUNT_SERVICE_URL:-http://192.168.1.111:4000}
|
||||
MPC_COORDINATOR_URL: ${MPC_COORDINATOR_URL:-http://192.168.1.111:8081}
|
||||
MPC_SESSION_COORDINATOR_URL: ${MPC_SESSION_COORDINATOR_URL:-http://192.168.1.111:8081}
|
||||
MPC_MESSAGE_ROUTER_WS_URL: ${MPC_MESSAGE_ROUTER_WS_URL:-ws://192.168.1.111:8082}
|
||||
MPC_SERVER_PARTY_API_URL: ${MPC_SERVER_PARTY_API_URL:-http://192.168.1.111:8083}
|
||||
MPC_API_KEY: ${MPC_API_KEY:-rwa-mpc-api-key-2024-secure-access-token}
|
||||
MPC_COORDINATOR_TIMEOUT: 30000
|
||||
# Share Encryption
|
||||
SHARE_MASTER_KEY: ${SHARE_MASTER_KEY:-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef}
|
||||
|
|
@ -42,86 +50,18 @@ services:
|
|||
MPC_KEYGEN_TIMEOUT: 300000
|
||||
MPC_SIGNING_TIMEOUT: 180000
|
||||
MPC_REFRESH_TIMEOUT: 300000
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
kafka:
|
||||
condition: service_started
|
||||
networks:
|
||||
- mpc-network
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/health"]
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3006/api/v1/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: rwa-mpc-postgres
|
||||
ports:
|
||||
- "5433:5432"
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_DB: rwa_mpc
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- mpc-network
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: rwa-mpc-redis
|
||||
ports:
|
||||
- "6380:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- mpc-network
|
||||
|
||||
zookeeper:
|
||||
image: confluentinc/cp-zookeeper:7.5.0
|
||||
container_name: rwa-mpc-zookeeper
|
||||
environment:
|
||||
ZOOKEEPER_CLIENT_PORT: 2181
|
||||
ZOOKEEPER_TICK_TIME: 2000
|
||||
networks:
|
||||
- mpc-network
|
||||
|
||||
kafka:
|
||||
image: confluentinc/cp-kafka:7.5.0
|
||||
container_name: rwa-mpc-kafka
|
||||
ports:
|
||||
- "9093:9092"
|
||||
environment:
|
||||
KAFKA_BROKER_ID: 1
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9093,PLAINTEXT_INTERNAL://kafka:29092
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
|
||||
depends_on:
|
||||
- zookeeper
|
||||
networks:
|
||||
- mpc-network
|
||||
- rwa-network
|
||||
|
||||
networks:
|
||||
mpc-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
# =============================================================================
|
||||
# Presence Service - Docker Compose (Production Stack)
|
||||
# Presence Service - Docker Compose (Development/Standalone)
|
||||
# =============================================================================
|
||||
# For production, use the root docker-compose.yml in ../
|
||||
#
|
||||
# For standalone development:
|
||||
# 1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
|
||||
# 2. Then: docker compose up -d --build
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
presence-service:
|
||||
build: .
|
||||
container_name: presence-service
|
||||
container_name: rwa-presence-service
|
||||
ports:
|
||||
- "3011:3011"
|
||||
environment:
|
||||
|
|
@ -13,18 +19,18 @@ services:
|
|||
- NODE_ENV=production
|
||||
- APP_PORT=3011
|
||||
- API_PREFIX=api/v1
|
||||
# Database
|
||||
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_presence?schema=public
|
||||
# Redis
|
||||
- REDIS_HOST=redis
|
||||
# Database (shared PostgreSQL)
|
||||
- DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_presence?schema=public
|
||||
# Redis (shared)
|
||||
- REDIS_HOST=rwa-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_PASSWORD=
|
||||
- REDIS_DB=0
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
||||
- REDIS_DB=10
|
||||
# JWT
|
||||
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
||||
# Kafka
|
||||
- JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
|
||||
# Kafka (shared)
|
||||
- KAFKA_ENABLED=true
|
||||
- KAFKA_BROKERS=kafka:29092
|
||||
- KAFKA_BROKERS=rwa-kafka:29092
|
||||
- KAFKA_CLIENT_ID=presence-service
|
||||
- KAFKA_GROUP_ID=presence-service-group
|
||||
# Presence
|
||||
|
|
@ -32,13 +38,6 @@ services:
|
|||
- SNAPSHOT_INTERVAL_SECONDS=60
|
||||
# Timezone
|
||||
- TZ=Asia/Shanghai
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3011/api/v1/health"]
|
||||
interval: 30s
|
||||
|
|
@ -47,90 +46,8 @@ services:
|
|||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- presence-network
|
||||
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: presence-postgres
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=rwa_presence
|
||||
ports:
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- presence-network
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: presence-redis
|
||||
ports:
|
||||
- "6380:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- presence-network
|
||||
|
||||
zookeeper:
|
||||
image: confluentinc/cp-zookeeper:7.5.0
|
||||
container_name: presence-zookeeper
|
||||
environment:
|
||||
ZOOKEEPER_CLIENT_PORT: 2181
|
||||
ZOOKEEPER_TICK_TIME: 2000
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "2181"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- presence-network
|
||||
|
||||
kafka:
|
||||
image: confluentinc/cp-kafka:7.5.0
|
||||
container_name: presence-kafka
|
||||
depends_on:
|
||||
zookeeper:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "9093:9092"
|
||||
environment:
|
||||
KAFKA_BROKER_ID: 1
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9093,PLAINTEXT_INTERNAL://kafka:29092
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "nc -z localhost 29092 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- presence-network
|
||||
- rwa-network
|
||||
|
||||
networks:
|
||||
presence-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
rwa-network:
|
||||
external: true
|
||||
|
|
|
|||
Loading…
Reference in New Issue