chore(identity-service): 完善 Docker Compose 配置
- 移除过时的 version 属性 - 补充完整环境变量 (Redis, Kafka, MPC, Backup Service) - 添加健康检查 (healthcheck) 配置 - 添加自动重启策略 (restart: unless-stopped) - 修复 Kafka broker 内部地址 (kafka:29092) - 配置 Zookeeper 健康检查和依赖条件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
769a33b9b0
commit
acb424a2da
|
|
@ -1,27 +1,50 @@
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
identity-service:
|
identity-service:
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
|
# Database
|
||||||
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_identity?schema=public
|
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_identity?schema=public
|
||||||
|
# JWT
|
||||||
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
- JWT_SECRET=your-super-secret-jwt-key-change-in-production
|
||||||
- JWT_ACCESS_EXPIRES_IN=2h
|
- JWT_ACCESS_EXPIRES_IN=2h
|
||||||
- JWT_REFRESH_EXPIRES_IN=30d
|
- JWT_REFRESH_EXPIRES_IN=30d
|
||||||
|
# Redis
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- KAFKA_BROKERS=kafka:9092
|
- REDIS_PASSWORD=
|
||||||
|
- REDIS_DB=0
|
||||||
|
# Kafka
|
||||||
|
- KAFKA_BROKERS=kafka:29092
|
||||||
|
- KAFKA_CLIENT_ID=identity-service
|
||||||
|
- KAFKA_GROUP_ID=identity-service-group
|
||||||
|
# App
|
||||||
- APP_PORT=3000
|
- APP_PORT=3000
|
||||||
- APP_ENV=production
|
- APP_ENV=production
|
||||||
|
# Blockchain
|
||||||
|
- WALLET_ENCRYPTION_SALT=rwa-wallet-salt-change-in-production
|
||||||
|
# MPC Service
|
||||||
|
- MPC_SERVICE_URL=http://mpc-service:3001
|
||||||
|
- MPC_MODE=local
|
||||||
|
# Backup Service
|
||||||
|
- BACKUP_SERVICE_URL=http://backup-service:3002
|
||||||
|
- BACKUP_SERVICE_ENABLED=false
|
||||||
|
- SERVICE_JWT_SECRET=your-service-jwt-secret-change-in-production
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
redis:
|
redis:
|
||||||
condition: service_started
|
condition: service_healthy
|
||||||
kafka:
|
kafka:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
|
|
@ -38,6 +61,7 @@ services:
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 10
|
retries: 10
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
|
|
@ -45,17 +69,30 @@ services:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
zookeeper:
|
zookeeper:
|
||||||
image: confluentinc/cp-zookeeper:7.5.0
|
image: confluentinc/cp-zookeeper:7.5.0
|
||||||
environment:
|
environment:
|
||||||
ZOOKEEPER_CLIENT_PORT: 2181
|
ZOOKEEPER_CLIENT_PORT: 2181
|
||||||
ZOOKEEPER_TICK_TIME: 2000
|
ZOOKEEPER_TICK_TIME: 2000
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-z", "localhost", "2181"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
image: confluentinc/cp-kafka:7.5.0
|
image: confluentinc/cp-kafka:7.5.0
|
||||||
depends_on:
|
depends_on:
|
||||||
- zookeeper
|
zookeeper:
|
||||||
|
condition: service_healthy
|
||||||
ports:
|
ports:
|
||||||
- "9092:9092"
|
- "9092:9092"
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -66,6 +103,14 @@ services:
|
||||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
|
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
|
||||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
|
||||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
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:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue