-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
266 lines (242 loc) · 9.01 KB
/
Copy pathdocker-compose.yml
File metadata and controls
266 lines (242 loc) · 9.01 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# DataPilot Docker Compose
#
# This file runs the complete DataPilot application:
# - PostgreSQL database
# - FastAPI backend API
# - Chainlit web UI
#
# Usage:
# docker-compose up -d # Start all services
# docker-compose logs -f # View logs
# docker-compose down # Stop all services
# docker-compose down -v # Stop and remove volumes
name: datapilot
services:
# ==========================================================================
# PostgreSQL Database
# ==========================================================================
postgres:
image: postgres:15-alpine
container_name: postgres
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
environment:
POSTGRES_USER: datapilot
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-datapilot_dev_password}
POSTGRES_DB: datapilot_db
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --no-instructions"
# Reduce PostgreSQL log verbosity (suppress routine startup/checkpoint details)
command: ["postgres", "-c", "log_min_messages=error", "-c", "log_checkpoints=off", "-c", "log_connections=off", "-c", "log_disconnections=off"]
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "${POSTGRES_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U datapilot -d datapilot_db"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- network
restart: unless-stopped
# ==========================================================================
# FastAPI Backend API
# ==========================================================================
backend-server:
init: true
build:
context: .
dockerfile: docker/Dockerfile
container_name: backend-server
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
environment:
# Database
DATABASE_URL: postgresql://datapilot:${DATABASE_PASSWORD:-datapilot_dev_password}@postgres:5432/datapilot_db
# Application
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
DEBUG: ${DEBUG:-false}
SECRET_KEY: ${SECRET_KEY:-change-this-in-production}
# Data paths (inside container)
SNAPDATA_PATH: /data
# LLM Configuration
LLM_PROVIDER: ${LLM_PROVIDER:-ollama}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
OLLAMA_BASE_URL: ${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
# Azure OpenAI Configuration (OpenAI-compatible endpoint)
AZURE_OPENAI_ENDPOINT: ${AZURE_OPENAI_ENDPOINT:-}
AZURE_OPENAI_API_KEY: ${AZURE_OPENAI_API_KEY:-}
# LLM Model Settings
LLM_SQL_MODEL: ${LLM_SQL_MODEL:-}
LLM_SQL_MAX_TOKENS: ${LLM_SQL_MAX_TOKENS:-2000}
LLM_SQL_TEMPERATURE: ${LLM_SQL_TEMPERATURE:-0.1}
LLM_KB_MODEL: ${LLM_KB_MODEL:-}
LLM_KB_MAX_TOKENS: ${LLM_KB_MAX_TOKENS:-150}
LLM_KB_MAX_DATA_SIZE: ${LLM_KB_MAX_DATA_SIZE:-8000}
LLM_KB_MAX_PROMPT_SIZE: ${LLM_KB_MAX_PROMPT_SIZE:-10000}
LLM_KB_TEMPERATURE: ${LLM_KB_TEMPERATURE:-}
# Query Result Settings
MAX_RESULT_COLUMNS: ${MAX_RESULT_COLUMNS:-10}
# Vanna Configuration
SQL_TRAINING_DATA_PATH: ${SQL_TRAINING_DATA_PATH:-./datasets/data/training}
SYSTEM_PROMPTS_PATH: ${SYSTEM_PROMPTS_PATH:-./datasets/data/prompts}
VANNA_CHROMADB_PATH: /app/chromadb
# Disable ChromaDB telemetry and tqdm progress bars
ANONYMIZED_TELEMETRY: "False"
TQDM_DISABLE: "1"
# Suppress noisy library warnings
PYTHONWARNINGS: "ignore::DeprecationWarning,ignore:urllib3.*doesn't match a supported version"
# ONNX Runtime optimization for LXC containers (Proxmox, etc.)
# CRITICAL: Multiple settings to prevent pthread_setaffinity_np errors
# See: https://github.com/chroma-core/chroma/issues/1420
OMP_NUM_THREADS: "4"
ORT_DISABLE_CPU_EP_AFFINITY: "1"
ORT_DISABLE_THREAD_AFFINITY: "1"
OMP_WAIT_POLICY: "PASSIVE"
OMP_PROC_BIND: "false"
ORT_LOG_LEVEL: "ERROR"
volumes:
- datapilot_data:/data
- ./docker/logs:/app/logs
- chromadb_data:/app/chromadb
- chroma_cache:/root/.cache/chroma # Persist ONNX embedding model (79MB)
ports:
- "${API_PORT:-8000}:8000"
depends_on:
postgres:
condition: service_healthy
networks:
- network
restart: unless-stopped
stop_grace_period: 10s
command: ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000", "--timeout-keep-alive", "5", "--limit-max-requests", "10000"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# ==========================================================================
# Chainlit Web UI
# ==========================================================================
frontend-server:
init: true
build:
context: .
dockerfile: docker/Dockerfile
container_name: frontend-server
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
environment:
# API connection (internal Docker network)
API_BASE_URL: http://backend-server:8000
# External API URL for browser download links
# Options: "relative" (behind reverse proxy), "http://localhost:8000" (local dev),
# or custom like "https://api.example.com"
API_EXTERNAL_URL: ${API_EXTERNAL_URL:-http://localhost:8000}
# Required by src.core.config (loaded by chainlit_app.py)
DATABASE_URL: postgresql://datapilot:${DATABASE_PASSWORD:-datapilot_dev_password}@postgres:5432/datapilot_db
SECRET_KEY: ${SECRET_KEY:-change-this-in-production}
ENVIRONMENT: ${ENVIRONMENT:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
SNAPDATA_PATH: /data
# LLM Configuration (needed for AI summary generation in Chainlit process)
LLM_PROVIDER: ${LLM_PROVIDER:-ollama}
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
OLLAMA_BASE_URL: ${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
AZURE_OPENAI_ENDPOINT: ${AZURE_OPENAI_ENDPOINT:-}
AZURE_OPENAI_API_KEY: ${AZURE_OPENAI_API_KEY:-}
LLM_SQL_MODEL: ${LLM_SQL_MODEL:-}
LLM_KB_MODEL: ${LLM_KB_MODEL:-}
# Chainlit settings
CHAINLIT_HOST: 0.0.0.0
CHAINLIT_PORT: 8001
CHAINLIT_AUTH_SECRET: ${CHAINLIT_AUTH_SECRET:-datapilot-default-auth-secret-change-in-production}
# Suppress verbose logging
CHAINLIT_DEBUG: "false"
# Suppress noisy library warnings
PYTHONWARNINGS: "ignore::DeprecationWarning,ignore:urllib3.*doesn't match a supported version"
# ONNX Runtime optimization (same as backend)
OMP_NUM_THREADS: "4"
ORT_DISABLE_CPU_EP_AFFINITY: "1"
ORT_DISABLE_THREAD_AFFINITY: "1"
OMP_WAIT_POLICY: "PASSIVE"
OMP_PROC_BIND: "false"
volumes:
- ./docker/logs:/app/logs
ports:
- "${CHAINLIT_PORT:-8001}:8001"
depends_on:
backend-server:
condition: service_healthy
data-loader:
condition: service_completed_successfully
networks:
- network
restart: unless-stopped
stop_grace_period: 10s
command: ["chainlit", "run", "chainlit_app.py", "--host", "0.0.0.0", "--port", "8001"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
# ==========================================================================
# Data Initialization (downloads data AND loads into database)
# ==========================================================================
data-loader:
init: true
build:
context: .
dockerfile: docker/Dockerfile
container_name: data-loader
environment:
DATABASE_URL: postgresql://datapilot:${DATABASE_PASSWORD:-datapilot_dev_password}@postgres:5432/datapilot_db
SNAPDATA_PATH: /data
SECRET_KEY: ${SECRET_KEY:-init-only}
# ONNX Runtime optimization
OMP_NUM_THREADS: "4"
ORT_DISABLE_CPU_EP_AFFINITY: "1"
ORT_DISABLE_THREAD_AFFINITY: "1"
OMP_WAIT_POLICY: "PASSIVE"
OMP_PROC_BIND: "false"
volumes:
- datapilot_data:/data
depends_on:
postgres:
condition: service_healthy
networks:
- network
command: python /app/scripts/docker_init_data.py
# =============================================================================
# Volumes
# =============================================================================
volumes:
postgres_data:
driver: local
datapilot_data:
driver: local
chromadb_data:
driver: local
chroma_cache:
driver: local
# =============================================================================
# Networks
# =============================================================================
networks:
network:
driver: bridge