Files
nofx/docker-compose.yml
T
2025-11-07 01:25:18 +08:00

112 lines
3.0 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.
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: nofx-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-nofx}
POSTGRES_USER: ${POSTGRES_USER:-nofx}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nofx123456}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "${POSTGRES_PORT:-5433}:5432"
networks:
- nofx-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nofx}"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:7-alpine
container_name: nofx-redis
restart: unless-stopped
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-redis123456}
volumes:
- redis_data:/data
ports:
- "${REDIS_PORT:-6380}:6379"
networks:
- nofx-network
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 3s
retries: 5
# 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
- ./beta_codes.txt:/app/beta_codes.txt:ro
- ./decision_logs:/app/decision_logs
- ./prompts:/app/prompts
- /etc/localtime:/etc/localtime:ro # Sync host time
environment:
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # Set timezone
- AI_MAX_TOKENS=4000 # AI响应的最大token数(默认2000,建议4000-8000
- DATA_ENCRYPTION_KEY=${DATA_ENCRYPTION_KEY} # 数据加密密钥
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-nofx}
- POSTGRES_USER=${POSTGRES_USER:-nofx}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-nofx123456}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis123456}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- nofx-network
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}:443"
volumes:
- ./certs:/etc/nginx/certs:ro # 挂载证书目录
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
volumes:
postgres_data:
redis_data: