refactor(docker): restructure Docker setup with dedicated backend/frontend services

This commit is contained in:
d0lwl0b
2025-10-30 13:11:29 +08:00
parent 907f660398
commit 0d52bc8ad9
6 changed files with 129 additions and 216 deletions
+15 -15
View File
@@ -1,11 +1,11 @@
version: '3.8'
services:
# NOFX Trading Backend
# Backend service (API and core logic)
nofx:
build:
context: .
dockerfile: Dockerfile
dockerfile: ./docker/Dockerfile.backend
container_name: nofx-trading
restart: unless-stopped
ports:
@@ -13,10 +13,9 @@ services:
volumes:
- ./config.json:/app/config.json:ro
- ./decision_logs:/app/decision_logs
- /etc/localtime:/etc/localtime:ro # 同步主机时间
- frontend-dist:/app/web/dist-shared:rw # 共享前端文件
- /etc/localtime:/etc/localtime:ro # Sync host time
environment:
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # 使用中国时区
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # Set timezone
networks:
- nofx-network
healthcheck:
@@ -25,26 +24,27 @@ services:
timeout: 10s
retries: 3
start_period: 60s
command: sh -c "cp -r /app/web/dist/* /app/web/dist-shared/ 2>/dev/null || true && exec ./nofx"
# Frontend (Nginx)
# Frontend service (static serving and proxy)
nofx-frontend:
image: nginx:alpine
build:
context: .
dockerfile: ./docker/Dockerfile.frontend
container_name: nofx-frontend
restart: unless-stopped
ports:
- "${NOFX_FRONTEND_PORT:-3000}:80"
volumes:
- frontend-dist:/usr/share/nginx/html:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- nofx-network
depends_on:
- nofx
volumes:
frontend-dist:
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
networks:
nofx-network:
driver: bridge
driver: bridge