-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.compose.dev.yaml
More file actions
184 lines (173 loc) · 6.72 KB
/
Copy pathdocker.compose.dev.yaml
File metadata and controls
184 lines (173 loc) · 6.72 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
name: cortex
services:
postgres:
image: postgres:16
environment:
POSTGRES_USER: cortex
POSTGRES_PASSWORD: cortex
POSTGRES_DB: cortex
healthcheck: { test: ["CMD-SHELL", "pg_isready -U cortex"], interval: 5s, timeout: 5s, retries: 10 }
volumes:
- postgres_data:/var/lib/postgresql/data
# Expose to localhost for gateway (host network mode) to connect
# Using non-standard ports to avoid conflicts with system services
ports:
- "127.0.0.1:${CORTEX_POSTGRES_PORT:-15432}:5432"
redis:
image: redis:7
volumes:
- redis_data:/data
# Expose to localhost for gateway (host network mode) to connect
# Using non-standard ports to avoid conflicts with system services
ports:
- "127.0.0.1:${CORTEX_REDIS_PORT:-16379}:6379"
gateway:
build:
context: ./backend
dockerfile: Dockerfile
# =========================================================================
# HOST NETWORK MODE - Universal External Access
# =========================================================================
# Using host network mode allows ANY Docker container or external application
# to reach the Cortex API at http://<HOST_IP>:8084 or http://host.docker.internal:8084
# without requiring manual network configuration.
#
# This is the recommended setup for integration with external applications
# like MAGE, LangChain, or any OpenAI-compatible client.
# =========================================================================
network_mode: host
env_file:
- ./backend/.env.dev
environment:
VLLM_GEN_URLS: ""
VLLM_EMB_URLS: ""
INTERNAL_VLLM_API_KEY: dev-internal-token
GATEWAY_DEV_ALLOW_ALL_KEYS: "true"
CORS_ENABLED: "true"
# Pass detected host IP to container for CORS configuration
HOST_IP: ${HOST_IP:-localhost}
# Dynamic CORS origins - with host network, allow from any origin for API access
# CORS only affects browser requests; server-to-server requests are unaffected
CORS_ALLOW_ORIGINS: http://${HOST_IP:-localhost}:3001,http://localhost:3001,http://127.0.0.1:3001,*
# Auto-bootstrap admin user on first startup (dev mode)
ADMIN_BOOTSTRAP_USERNAME: ${ADMIN_BOOTSTRAP_USERNAME:-admin}
ADMIN_BOOTSTRAP_PASSWORD: ${ADMIN_BOOTSTRAP_PASSWORD:-admin}
ADMIN_BOOTSTRAP_ORG: ${ADMIN_BOOTSTRAP_ORG:-Default}
NVIDIA_VISIBLE_DEVICES: all
NVIDIA_DRIVER_CAPABILITIES: compute,utility
# Inside the container, always use the container mount points
CORTEX_MODELS_DIR: /var/cortex/models
HF_CACHE_DIR: /var/cortex/hf-cache
# Explicitly pass host paths for Docker-managed vLLM containers
CORTEX_MODELS_DIR_HOST: ${CORTEX_MODELS_DIR:-/var/cortex/models}
HF_CACHE_DIR_HOST: ${HF_CACHE_DIR:-/var/cortex/hf-cache}
# Keep in sync with backend/src/config.py and scripts/prepare-offline-deployment.sh
# NOTE: Qwen3 requires newer Transformers, so default to a compatible image.
VLLM_IMAGE: ${VLLM_IMAGE:-vllm/vllm-openai:latest}
# Database and Redis URLs - use localhost since gateway is on host network
# Using non-standard ports to avoid conflicts with system services
DATABASE_URL: postgresql+asyncpg://cortex:cortex@127.0.0.1:${CORTEX_POSTGRES_PORT:-15432}/cortex
REDIS_URL: redis://127.0.0.1:${CORTEX_REDIS_PORT:-16379}/0
# Prometheus URL - use localhost
PROMETHEUS_URL: http://127.0.0.1:${PROM_PORT:-9090}
# Note: 'ports' is not used with network_mode: host - container uses host ports directly
depends_on:
- redis
- postgres
# Gateway does not require GPU; avoid reserving VRAM on dev hosts
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${CORTEX_MODELS_DIR:-/var/cortex/models}:/var/cortex/models
- ${HF_CACHE_DIR:-/var/cortex/hf-cache}:/var/cortex/hf-cache
# Persist Deployment exports (manifests/images/db dumps) on host
- ${CORTEX_EXPORT_DIR:-/var/cortex/exports}:/var/cortex/exports
# Note: Gateway does not require GPU. Removed device reservations to allow startup on hosts
# without NVIDIA runtime. GPU metrics are provided via dcgm-exporter profile when enabled.
# Models directory is read-write to allow multi-part GGUF merging
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
environment:
# Frontend automatically detects gateway URL from browser hostname
# No NEXT_PUBLIC_GATEWAY_URL needed - uses dynamic detection
NODE_ENV: development
# Override host IP detection for GUI display
NEXT_PUBLIC_HOST_IP: ${HOST_IP:-localhost}
ports: ["${FRONTEND_PORT:-3001}:3001"]
depends_on:
- gateway
volumes:
- ./frontend:/app
- /app/node_modules
- /app/.next
prometheus:
image: prom/prometheus:latest
volumes:
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
ports: ["${PROM_PORT:-9090}:9090"]
# Enable host.docker.internal resolution for reaching gateway on host network
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on: [gateway]
command: ["--config.file=/etc/prometheus/prometheus.yml","--storage.tsdb.retention.time=7d"]
node-exporter:
image: prom/node-exporter:latest
pid: host
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
profiles: ["linux"]
dcgm-exporter:
image: nvidia/dcgm-exporter:latest
# Request GPU access via Compose devices (works on Docker Desktop with WSL2 GPU support)
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu, utility, compute]
runtime: nvidia
cap_add:
- SYS_ADMIN
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
ports:
- "9400:9400"
profiles: ["gpu"]
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
privileged: true
ports: ["8085:8084"]
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
profiles: ["linux"]
pgadmin:
image: dpage/pgadmin4:8.7
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
depends_on:
- postgres
volumes:
- pgadmin_data:/var/lib/pgadmin
volumes:
postgres_data:
redis_data:
prometheus_data:
pgadmin_data:
# Add Grafana and Admin UI later (Phase 4/6)