97 lines
2.5 KiB
YAML
97 lines
2.5 KiB
YAML
# =============================================================================
|
|
# Admin Service - Docker Compose Configuration
|
|
# =============================================================================
|
|
# 用途: 本地开发和独立部署 admin-service
|
|
# 启动: docker compose up -d
|
|
# =============================================================================
|
|
|
|
services:
|
|
admin-service:
|
|
build: .
|
|
container_name: rwa-admin-service
|
|
ports:
|
|
- "3010:3010"
|
|
environment:
|
|
# Application
|
|
- NODE_ENV=production
|
|
- APP_PORT=3010
|
|
- API_PREFIX=api/v1
|
|
# Database
|
|
- DATABASE_URL=postgresql://postgres:password@postgres:5432/rwa_admin?schema=public
|
|
# JWT
|
|
- JWT_SECRET=your-admin-jwt-secret-change-in-production
|
|
- JWT_EXPIRES_IN=7d
|
|
# Redis (可选)
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- 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
|
|
timeout: 10s
|
|
retries: 3
|
|
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
|
|
|
|
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
|