refactor(docker): 2.0系统共享1.0基础设施并保持完全隔离
- 网络: 使用共享的 rwa-network (external) - 数据库: 连接 postgres:5432,使用独立数据库名 - Redis: 连接 redis:6379,使用 DB 10-14 分区隔离 - Kafka: 连接 kafka:29092,仅消费 CDC 事件(单向同步) - 服务依赖: 添加 postgres/redis/kafka 健康检查依赖 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
821c70bf38
commit
6ffde0f4c6
|
|
@ -2,7 +2,11 @@
|
|||
# RWA Mining Ecosystem 2.0 - Docker Compose
|
||||
# =============================================================================
|
||||
#
|
||||
# 2.0 系统完全独立于 1.0,可随时重置
|
||||
# 2.0 系统共享 1.0 的基础设施 (PostgreSQL, Redis, Kafka),但完全隔离:
|
||||
# - 数据库:使用独立的数据库名称 (rwa_contribution, rwa_mining, etc.)
|
||||
# - Redis:使用独立的 DB 分区 (DB 10-15)
|
||||
# - Kafka:仅通过 CDC 消费 1.0 的数据变更事件,单向同步
|
||||
# - HTTP:2.0 服务之间互相调用,不调用 1.0 服务
|
||||
#
|
||||
# Usage:
|
||||
# docker-compose -f docker-compose.2.0.yml up -d # 启动所有 2.0 服务
|
||||
|
|
@ -22,15 +26,26 @@ services:
|
|||
context: ./contribution-service
|
||||
dockerfile: Dockerfile
|
||||
container_name: rwa-contribution-service
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
TZ: Asia/Shanghai
|
||||
PORT: 3020
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/rwa_contribution?schema=public
|
||||
REDIS_HOST: ${REDIS_HOST:-host.docker.internal}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
# PostgreSQL - 使用独立的数据库
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/rwa_contribution?schema=public
|
||||
# Redis - 使用 DB 10 隔离
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
KAFKA_BROKERS: ${KAFKA_BROKERS:-host.docker.internal:9092}
|
||||
REDIS_DB: 10
|
||||
# Kafka - 消费 CDC 事件
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
CDC_TOPIC_ADOPTIONS: ${CDC_TOPIC_ADOPTIONS:-dbserver1.public.adoptions}
|
||||
CDC_TOPIC_PAYMENTS: ${CDC_TOPIC_PAYMENTS:-dbserver1.public.payment_records}
|
||||
CDC_CONSUMER_GROUP: contribution-service-cdc-group
|
||||
|
|
@ -44,7 +59,7 @@ services:
|
|||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
mining-service:
|
||||
build:
|
||||
|
|
@ -52,17 +67,27 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: rwa-mining-service
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
contribution-service:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
TZ: Asia/Shanghai
|
||||
PORT: 3021
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/rwa_mining?schema=public
|
||||
REDIS_HOST: ${REDIS_HOST:-host.docker.internal}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
# PostgreSQL - 使用独立的数据库
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/rwa_mining?schema=public
|
||||
# Redis - 使用 DB 11 隔离
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
KAFKA_BROKERS: ${KAFKA_BROKERS:-host.docker.internal:9092}
|
||||
REDIS_DB: 11
|
||||
# Kafka
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
ports:
|
||||
- "3021:3021"
|
||||
healthcheck:
|
||||
|
|
@ -73,7 +98,7 @@ services:
|
|||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
trading-service:
|
||||
build:
|
||||
|
|
@ -81,17 +106,28 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: rwa-trading-service
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
mining-service:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
TZ: Asia/Shanghai
|
||||
PORT: 3022
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/rwa_trading?schema=public
|
||||
REDIS_HOST: ${REDIS_HOST:-host.docker.internal}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
# PostgreSQL - 使用独立的数据库
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/rwa_trading?schema=public
|
||||
# Redis - 使用 DB 12 隔离
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
KAFKA_BROKERS: ${KAFKA_BROKERS:-host.docker.internal:9092}
|
||||
REDIS_DB: 12
|
||||
# Kafka
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
# 2.0 内部服务调用
|
||||
MINING_SERVICE_URL: http://mining-service:3021
|
||||
ports:
|
||||
- "3022:3022"
|
||||
|
|
@ -103,7 +139,7 @@ services:
|
|||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
mining-admin-service:
|
||||
build:
|
||||
|
|
@ -111,6 +147,10 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: rwa-mining-admin-service
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
contribution-service:
|
||||
condition: service_healthy
|
||||
mining-service:
|
||||
|
|
@ -119,10 +159,14 @@ services:
|
|||
NODE_ENV: production
|
||||
TZ: Asia/Shanghai
|
||||
PORT: 3023
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/rwa_mining_admin?schema=public
|
||||
REDIS_HOST: ${REDIS_HOST:-host.docker.internal}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
# PostgreSQL - 使用独立的数据库
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/rwa_mining_admin?schema=public
|
||||
# Redis - 使用 DB 13 隔离
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
REDIS_DB: 13
|
||||
# 2.0 内部服务调用
|
||||
CONTRIBUTION_SERVICE_URL: http://contribution-service:3020
|
||||
MINING_SERVICE_URL: http://mining-service:3021
|
||||
TRADING_SERVICE_URL: http://trading-service:3022
|
||||
|
|
@ -137,27 +181,40 @@ services:
|
|||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
auth-service:
|
||||
build:
|
||||
context: ./auth-service
|
||||
dockerfile: Dockerfile
|
||||
container_name: rwa-auth-service
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
kafka:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
TZ: Asia/Shanghai
|
||||
PORT: 3024
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/rwa_auth?schema=public
|
||||
REDIS_HOST: ${REDIS_HOST:-host.docker.internal}
|
||||
REDIS_PORT: ${REDIS_PORT:-6379}
|
||||
# PostgreSQL - 使用独立的数据库
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@postgres:5432/rwa_auth?schema=public
|
||||
# Redis - 使用 DB 14 隔离
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||
KAFKA_BROKERS: ${KAFKA_BROKERS:-host.docker.internal:9092}
|
||||
REDIS_DB: 14
|
||||
# Kafka - 消费 CDC 事件
|
||||
KAFKA_BROKERS: kafka:29092
|
||||
CDC_TOPIC_USERS: ${CDC_TOPIC_USERS:-dbserver1.public.users}
|
||||
CDC_CONSUMER_GROUP: auth-service-cdc-group
|
||||
# JWT 配置
|
||||
JWT_SECRET: ${JWT_SECRET:-your-jwt-secret-change-in-production}
|
||||
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
|
||||
JWT_REFRESH_EXPIRES_IN: ${JWT_REFRESH_EXPIRES_IN:-30d}
|
||||
# SMS 配置
|
||||
SMS_ACCESS_KEY_ID: ${SMS_ACCESS_KEY_ID:-}
|
||||
SMS_ACCESS_KEY_SECRET: ${SMS_ACCESS_KEY_SECRET:-}
|
||||
SMS_SIGN_NAME: ${SMS_SIGN_NAME:-榴莲生态}
|
||||
|
|
@ -172,7 +229,7 @@ services:
|
|||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
# ===========================================================================
|
||||
# Frontend Services (2.0)
|
||||
|
|
@ -202,9 +259,12 @@ services:
|
|||
start_period: 15s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- rwa-2.0-network
|
||||
- rwa-network
|
||||
|
||||
# =============================================================================
|
||||
# 网络配置 - 使用 1.0 的共享网络
|
||||
# =============================================================================
|
||||
networks:
|
||||
rwa-2.0-network:
|
||||
driver: bridge
|
||||
name: rwa-2.0-network
|
||||
rwa-network:
|
||||
external: true
|
||||
name: rwa-network
|
||||
|
|
|
|||
Loading…
Reference in New Issue