mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 01:48:22 +08:00
Feat: Upgrade Docker deployment with multi-stage build and Nginx integration
- Upgrade Dockerfile to Go 1.24 with multi-stage build (backend + frontend) - Add TA-Lib installation for technical analysis support - Integrate frontend build into main container image - Add Nginx reverse proxy configuration for API routing - Update docker-compose.yml to simplified single-container architecture - Update .dockerignore to include web source for build - Improve health checks and startup time handling Benefits: - One-click deployment with single Docker image - Better resource utilization with multi-stage build - Production-ready Nginx frontend serving - Easier maintenance and deployment Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
+14
-39
@@ -1,24 +1,21 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# 后端服务
|
||||
backend:
|
||||
# NOFX Trading Backend
|
||||
nofx:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: nofx-backend
|
||||
container_name: nofx-trading
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
# 挂载配置文件(必须)
|
||||
- ./config.json:/app/config.json:ro
|
||||
# 持久化决策日志
|
||||
- ./decision_logs:/app/decision_logs
|
||||
# 持久化币种池缓存
|
||||
- ./coin_pool_cache:/app/coin_pool_cache
|
||||
- /etc/localtime:/etc/localtime:ro # 同步主机时间
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- TZ=Asia/Shanghai # 使用中国时区
|
||||
networks:
|
||||
- nofx-network
|
||||
healthcheck:
|
||||
@@ -26,45 +23,23 @@ services:
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
start_period: 60s
|
||||
|
||||
# 前端服务
|
||||
frontend:
|
||||
build:
|
||||
context: ./web
|
||||
dockerfile: Dockerfile
|
||||
# Frontend (Nginx)
|
||||
nofx-frontend:
|
||||
image: nginx:alpine
|
||||
container_name: nofx-frontend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:80"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./web/dist:/usr/share/nginx/html:ro
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- nofx-network
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
depends_on:
|
||||
- nofx
|
||||
|
||||
networks:
|
||||
nofx-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
decision_logs:
|
||||
coin_pool_cache:
|
||||
|
||||
Reference in New Issue
Block a user