-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
145 lines (141 loc) · 5.28 KB
/
docker-compose.yml
File metadata and controls
145 lines (141 loc) · 5.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# docker-compose.yml - Main application services
# Architecture: backend container runs both HTTP API (port 6666) and MCP server (port 8001).
# No separate stock-mcp container is needed.
#
# Usage:
# Full deployment: docker compose -f docker-compose.yml -f docker-compose.infra.yml up -d
# App only: docker compose up -d (connect to existing infra)
# Development: docker compose -f docker-compose.yml -f docker-compose.infra.yml -f docker-compose.dev.yml up
#
# (docker-compose v1 also works: docker-compose ...)
services:
backend:
build:
context: .
dockerfile: docker/Dockerfile.backend
container_name: stock-backend
restart: unless-stopped
ports:
- "${MCP_PORT:-8001}:8001" # MCP streamable HTTP endpoint (/messages)
expose:
- "6666" # Backend HTTP API
- "8001" # MCP server (embedded in backend container)
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
# Timezone
TZ: Asia/Shanghai
# ClickHouse - defaults to stock-clickhouse on the docker network
CLICKHOUSE_HOST: ${DOCKER_CLICKHOUSE_HOST:-stock-clickhouse}
CLICKHOUSE_PORT: ${DOCKER_CLICKHOUSE_PORT:-9000}
CLICKHOUSE_HTTP_PORT: ${DOCKER_CLICKHOUSE_HTTP_PORT:-8123}
CLICKHOUSE_USER: ${CLICKHOUSE_USER:-default}
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-}
CLICKHOUSE_DATABASE: ${CLICKHOUSE_DATABASE:-stock_datasource}
# Redis (compose deployment uses redis over docker network)
REDIS_HOST: ${DOCKER_REDIS_HOST:-stock-redis}
REDIS_PORT: ${DOCKER_REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
REDIS_DB: ${REDIS_DB:-1}
# Langfuse (默认用宿主机)
LANGFUSE_HOST: ${LANGFUSE_HOST:-http://host.docker.internal:3000}
LANGFUSE_PUBLIC_KEY: ${LANGFUSE_PUBLIC_KEY:-}
LANGFUSE_SECRET_KEY: ${LANGFUSE_SECRET_KEY:-}
# API Keys
TUSHARE_TOKEN: ${TUSHARE_TOKEN:-}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
OPENAI_BASE_URL: ${OPENAI_BASE_URL:-https://api.openai.com/v1}
OPENAI_MODEL: ${OPENAI_MODEL:-gpt-4}
# Auth / Registration
AUTH_EMAIL_WHITELIST_ENABLED: ${AUTH_EMAIL_WHITELIST_ENABLED:-false}
AUTH_EMAIL_WHITELIST_FILE: ${AUTH_EMAIL_WHITELIST_FILE:-data/email.txt}
# MCP auth / usage reconciliation
MCP_JWT_PUBLIC_KEY_PATH: /run/secrets/mcp_jwt_public.pem
MCP_USAGE_REPORT_KEY: ${MCP_USAGE_REPORT_KEY:-}
MCP_INTERNAL_BEARER: ${MCP_INTERNAL_BEARER:-stock-datasource-internal}
# WeKnora Knowledge Base (optional)
WEKNORA_ENABLED: ${WEKNORA_ENABLED:-false}
WEKNORA_BASE_URL: ${WEKNORA_BASE_URL:-http://weknora-app:8080/api/v1}
WEKNORA_API_KEY: ${WEKNORA_API_KEY:-}
WEKNORA_KB_IDS: ${WEKNORA_KB_IDS:-}
WEKNORA_TIMEOUT: ${WEKNORA_TIMEOUT:-10}
volumes:
- ./src:/app/src
- ./skills:/app/skills
- ./.local:/app/.local
- ./logs:/app/logs
- ./data:/app/data
- ${MCP_JWT_PUBLIC_KEY_HOST_PATH:-/home/jq/code/nps_enhanced/conf/jwt_public.pem}:/run/secrets/mcp_jwt_public.pem:ro
networks:
- stock_network
- langfuse_default
command: ["uv", "run", "--no-sync", "python", "-m", "stock_datasource.services.backend_container"]
healthcheck:
test: curl -f http://localhost:6666/health && curl -f http://localhost:8001/health || exit 1
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
frontend:
build:
context: ./frontend
dockerfile: ../docker/Dockerfile.frontend
target: ${FRONTEND_TARGET:-production}
container_name: stock-frontend
restart: unless-stopped
ports:
- "${APP_PORT:-18080}:6666"
environment:
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-}
networks:
- stock_network
dns:
- 127.0.0.11
depends_on:
backend:
condition: service_healthy
# Task worker for processing sync tasks from Redis queue
worker:
build:
context: .
dockerfile: docker/Dockerfile.backend
container_name: stock-worker
restart: unless-stopped
command: ["uv", "run", "--no-sync", "python", "-m", "stock_datasource.services.task_worker", "--workers", "2"]
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
# Timezone
TZ: Asia/Shanghai
# ClickHouse - defaults to stock-clickhouse on the docker network
CLICKHOUSE_HOST: ${DOCKER_CLICKHOUSE_HOST:-stock-clickhouse}
CLICKHOUSE_PORT: ${DOCKER_CLICKHOUSE_PORT:-9000}
CLICKHOUSE_HTTP_PORT: ${DOCKER_CLICKHOUSE_HTTP_PORT:-8123}
CLICKHOUSE_USER: ${CLICKHOUSE_USER:-default}
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-}
CLICKHOUSE_DATABASE: ${CLICKHOUSE_DATABASE:-stock_datasource}
# Redis (compose deployment uses redis over docker network)
REDIS_HOST: ${DOCKER_REDIS_HOST:-stock-redis}
REDIS_PORT: ${DOCKER_REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
REDIS_DB: ${REDIS_DB:-1}
# API Keys
TUSHARE_TOKEN: ${TUSHARE_TOKEN:-}
volumes:
- ./src:/app/src
- ./logs:/app/logs
- ./data:/app/data
networks:
- stock_network
- langfuse_default
depends_on:
backend:
condition: service_healthy
healthcheck:
disable: true
networks:
stock_network:
name: stock_network
driver: bridge
langfuse_default:
external: true