trading.ai/docker-compose.yml
2025-09-18 20:54:30 +08:00

95 lines
2.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

version: '3.8'
services:
# 交易系统Web应用
trading-web:
build: .
container_name: trading-ai-web
ports:
- "8080:8080"
volumes:
# 数据持久化
- ./data:/app/data
# 配置文件
- ./config:/app/config
# 日志文件
- ./logs:/app/logs
environment:
- FLASK_ENV=production
- PYTHONPATH=/app
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/stats"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- trading-network
# 数据采集服务(可选)
trading-collector:
build: .
container_name: trading-ai-collector
volumes:
- ./data:/app/data
- ./config:/app/config
- ./logs:/app/logs
environment:
- PYTHONPATH=/app
# 运行数据采集脚本
command: python -c "
import time
import schedule
from src.strategy.kline_pattern_strategy import KlinePatternStrategy
from src.utils.config_loader import ConfigLoader
from loguru import logger
def run_strategy():
try:
config = ConfigLoader()
strategy = KlinePatternStrategy(config)
logger.info('开始运行策略扫描...')
# 这里可以添加具体的策略运行逻辑
logger.info('策略扫描完成')
except Exception as e:
logger.error(f'策略运行失败: {e}')
# 每天9点和15点运行策略
schedule.every().day.at('09:00').do(run_strategy)
schedule.every().day.at('15:00').do(run_strategy)
logger.info('数据采集服务已启动')
while True:
schedule.run_pending()
time.sleep(60)
"
restart: unless-stopped
depends_on:
- trading-web
networks:
- trading-network
# Nginx反向代理可选
nginx:
image: nginx:alpine
container_name: trading-ai-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- trading-web
restart: unless-stopped
networks:
- trading-network
networks:
trading-network:
driver: bridge
volumes:
trading-data:
driver: local