mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-30 17:41:22 +08:00
69 lines
1.7 KiB
YAML
69 lines
1.7 KiB
YAML
services:
|
|
# Init service: ensure config.db file exists before backend starts
|
|
config-init:
|
|
image: busybox:1.36
|
|
command:
|
|
- sh
|
|
- -c
|
|
- >
|
|
touch /mnt/config.db &&
|
|
if [ ! -f /mnt/config.json ] && [ -f /mnt/config.json.example ]; then
|
|
cp /mnt/config.json.example /mnt/config.json;
|
|
fi
|
|
volumes:
|
|
- ./:/mnt
|
|
restart: "no"
|
|
|
|
# Backend service (API and core logic)
|
|
nofx:
|
|
build:
|
|
context: .
|
|
dockerfile: ./docker/Dockerfile.backend
|
|
container_name: nofx-trading
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${NOFX_BACKEND_PORT:-8080}:8080"
|
|
volumes:
|
|
- ./config.json:/app/config.json:ro
|
|
- ./config.db:/app/config.db
|
|
- ./decision_logs:/app/decision_logs
|
|
- ./prompts:/app/prompts
|
|
- /etc/localtime:/etc/localtime:ro # Sync host time
|
|
environment:
|
|
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # Set timezone
|
|
networks:
|
|
- nofx-network
|
|
depends_on:
|
|
config-init:
|
|
condition: service_completed_successfully
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# Frontend service (static serving and proxy)
|
|
nofx-frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: ./docker/Dockerfile.frontend
|
|
container_name: nofx-frontend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${NOFX_FRONTEND_PORT:-3000}:80"
|
|
networks:
|
|
- nofx-network
|
|
depends_on:
|
|
- nofx
|
|
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
|