You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.3 KiB
108 lines
2.3 KiB
|
2 months ago
|
version: '3.8'
|
||
|
|
|
||
|
|
services:
|
||
|
|
# TimescaleDB (时序数据库)
|
||
|
|
timescaledb:
|
||
|
|
image: timescale/timescaledb:latest-pg15
|
||
|
|
container_name: kline_timescaledb
|
||
|
|
environment:
|
||
|
|
POSTGRES_USER: postgres
|
||
|
|
POSTGRES_PASSWORD: postgres
|
||
|
|
POSTGRES_DB: kline_data
|
||
|
|
ports:
|
||
|
|
- "5432:5432"
|
||
|
|
volumes:
|
||
|
|
- timescaledb_data:/var/lib/postgresql/data
|
||
|
|
networks:
|
||
|
|
- kline_network
|
||
|
|
restart: unless-stopped
|
||
|
|
healthcheck:
|
||
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||
|
|
interval: 10s
|
||
|
|
timeout: 5s
|
||
|
|
retries: 5
|
||
|
|
|
||
|
|
# Redis (缓存和消息队列)
|
||
|
|
redis:
|
||
|
|
image: redis:7-alpine
|
||
|
|
container_name: kline_redis
|
||
|
|
ports:
|
||
|
|
- "6379:6379"
|
||
|
|
volumes:
|
||
|
|
- redis_data:/data
|
||
|
|
networks:
|
||
|
|
- kline_network
|
||
|
|
restart: unless-stopped
|
||
|
|
command: redis-server --appendonly yes
|
||
|
|
healthcheck:
|
||
|
|
test: ["CMD", "redis-cli", "ping"]
|
||
|
|
interval: 10s
|
||
|
|
timeout: 5s
|
||
|
|
retries: 5
|
||
|
|
|
||
|
|
# 后端服务
|
||
|
|
backend:
|
||
|
|
build:
|
||
|
|
context: ./backend
|
||
|
|
dockerfile: Dockerfile
|
||
|
|
container_name: kline_backend
|
||
|
|
environment:
|
||
|
|
- DEBUG=false
|
||
|
|
- SECRET_KEY=your-production-secret-key-change-this
|
||
|
|
- TIMESCALE_DB_URL=postgresql://postgres:postgres@timescaledb:5432/kline_data
|
||
|
|
- SQLITE_DB_PATH=/app/data/config.db
|
||
|
|
- REDIS_URL=redis://redis:6379/0
|
||
|
|
- LOG_LEVEL=INFO
|
||
|
|
ports:
|
||
|
|
- "8000:8000"
|
||
|
|
volumes:
|
||
|
|
- backend_data:/app/data
|
||
|
|
depends_on:
|
||
|
|
timescaledb:
|
||
|
|
condition: service_healthy
|
||
|
|
redis:
|
||
|
|
condition: service_healthy
|
||
|
|
networks:
|
||
|
|
- kline_network
|
||
|
|
restart: unless-stopped
|
||
|
|
|
||
|
|
# 前端服务
|
||
|
|
frontend:
|
||
|
|
build:
|
||
|
|
context: ./frontend
|
||
|
|
dockerfile: Dockerfile
|
||
|
|
container_name: kline_frontend
|
||
|
|
ports:
|
||
|
|
- "80:80"
|
||
|
|
depends_on:
|
||
|
|
- backend
|
||
|
|
networks:
|
||
|
|
- kline_network
|
||
|
|
restart: unless-stopped
|
||
|
|
|
||
|
|
# Nginx (可选,如果需要额外的反向代理)
|
||
|
|
nginx:
|
||
|
|
image: nginx:alpine
|
||
|
|
container_name: kline_nginx
|
||
|
|
ports:
|
||
|
|
- "8080:80"
|
||
|
|
volumes:
|
||
|
|
- ./deploy/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||
|
|
depends_on:
|
||
|
|
- frontend
|
||
|
|
- backend
|
||
|
|
networks:
|
||
|
|
- kline_network
|
||
|
|
restart: unless-stopped
|
||
|
|
profiles:
|
||
|
|
- with-nginx
|
||
|
|
|
||
|
|
networks:
|
||
|
|
kline_network:
|
||
|
|
driver: bridge
|
||
|
|
|
||
|
|
volumes:
|
||
|
|
timescaledb_data:
|
||
|
|
redis_data:
|
||
|
|
backend_data:
|