-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
488 lines (431 loc) · 14.8 KB
/
docker-compose.yml
File metadata and controls
488 lines (431 loc) · 14.8 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# SynthStack Docker Compose - Development Environment
# AI-Native SaaS Boilerplate
#
# Container names and network can be customized via environment variables:
# CONTAINER_PREFIX=myapp docker compose up -d
#
# All container names will be prefixed with your custom name.
# See docs/REBRANDING_GUIDE.md for complete instructions.
services:
# ============================================
# PostgreSQL Database
# ============================================
postgres:
image: pgvector/pgvector:pg15
container_name: ${CONTAINER_PREFIX:-synthstack}-postgres
env_file:
- .env
environment:
POSTGRES_DB: ${DB_DATABASE:-synthstack}
POSTGRES_USER: ${DB_USER:-synthstack}
POSTGRES_PASSWORD: ${DB_PASSWORD:-change-this-password}
ports:
- "5499:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
# Note: App migrations run after Directus creates its schema (via directus-migrate service)
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${DB_USER:-synthstack} -d ${DB_DATABASE:-synthstack}" ]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- synthstack
# ============================================
# Redis Cache
# ============================================
redis:
image: redis:7-alpine
container_name: ${CONTAINER_PREFIX:-synthstack}-redis
command: redis-server --appendonly yes
ports:
- "6399:6379"
volumes:
- redis_data:/data
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- synthstack
# ============================================
# Qdrant Vector Database (for AI Copilot RAG)
# ============================================
qdrant:
image: qdrant/qdrant:v1.7.4
container_name: ${CONTAINER_PREFIX:-synthstack}-qdrant
ports:
- "6333:6333" # HTTP API
- "6334:6334" # gRPC API
volumes:
- qdrant_data:/qdrant/storage
environment:
QDRANT__SERVICE__GRPC_PORT: 6334
QDRANT__SERVICE__HTTP_PORT: 6333
healthcheck:
test: [ "CMD-SHELL", "bash -c 'exec 3<>/dev/tcp/localhost/6333 && printf \"GET /healthz HTTP/1.1\\r\\nHost: localhost\\r\\n\\r\\n\" >&3'" ]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- synthstack
# ============================================
# Directus CMS
# ============================================
directus:
build:
context: ./services/directus
dockerfile: Dockerfile
# Using regular Dockerfile instead of Dockerfile.custom to avoid Zod v4 conflicts
# with @directus-labs/collaborative-editing extension
container_name: ${CONTAINER_PREFIX:-synthstack}-directus
ports:
- "8099:8055"
env_file:
- .env
environment:
# Security Keys
KEY: ${DIRECTUS_KEY:-synthstack-key-change-in-production}
SECRET: ${DIRECTUS_SECRET:-synthstack-secret-change-in-production}
# Database
DB_CLIENT: pg
DB_HOST: postgres
DB_PORT: 5432
DB_DATABASE: ${DB_DATABASE:-synthstack}
DB_USER: ${DB_USER:-synthstack}
DB_PASSWORD: ${DB_PASSWORD:-change-this-password}
# Cache
CACHE_ENABLED: "true"
CACHE_STORE: redis
REDIS: redis://redis:6379
# Admin
ADMIN_EMAIL: ${DIRECTUS_ADMIN_EMAIL:-admin@synthstack.app}
ADMIN_PASSWORD: ${DIRECTUS_ADMIN_PASSWORD:-change-this-password}
ADMIN_TOKEN: ${DIRECTUS_ADMIN_TOKEN:-replace-with-secure-token}
# CORS
PUBLIC_URL: ${DIRECTUS_PUBLIC_URL:-http://localhost:8099}
CORS_ENABLED: "true"
CORS_ORIGIN: "http://localhost:3050,http://localhost:3003,http://localhost:8099"
# Storage
STORAGE_LOCATIONS: local
STORAGE_LOCAL_ROOT: ./uploads
# Logging
LOG_LEVEL: info
LOG_STYLE: pretty
# Extensions
EXTENSIONS_AUTO_RELOAD: "true"
# WebSockets (for Collaborative Editing)
# Temporarily disabled due to Zod v4 compatibility issue
# See: https://github.com/directus/directus/issues/25766
WEBSOCKETS_ENABLED: "false"
REALTIME_LOGS_ENABLED: "false"
# Visual Editor (Content Security Policy)
CONTENT_SECURITY_POLICY_DIRECTIVES__FRAME_SRC: "http://localhost:3050"
# Cache Auto-Purge (for Visual Editor)
CACHE_AUTO_PURGE: "true"
# Marketplace Trust (for Extension Installation)
MARKETPLACE_TRUST: "sandbox"
# SynthStack Branding
PROJECT_NAME: "SynthStack"
PROJECT_DESCRIPTOR: "Your Agency in a Box"
PROJECT_COLOR: "#6366F1"
PROJECT_LOGO: "/public/logo.svg"
PROJECT_LOGO_DARK: "/public/logo.svg"
PUBLIC_FAVICON: "/public/favicon.svg"
DEFAULT_APPEARANCE: "dark"
volumes:
- directus_uploads:/directus/uploads
- ./services/directus/extensions:/directus/extensions
- ./services/directus/snapshots:/directus/snapshots
- ./services/directus/public:/directus/public
- ./services/directus/migrations:/directus/migrations
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://0.0.0.0:8055/server/ping || exit 1" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
restart: unless-stopped
networks:
- synthstack
# ============================================
# Directus Init (Create Demo User)
# ============================================
directus-init:
image: curlimages/curl:latest
container_name: ${CONTAINER_PREFIX:-synthstack}-directus-init
env_file:
- .env
environment:
DIRECTUS_URL: http://directus:8055
DIRECTUS_ADMIN_TOKEN: ${DIRECTUS_ADMIN_TOKEN:-replace-with-secure-token}
depends_on:
directus:
condition: service_healthy
entrypoint: [ "/bin/sh", "-c" ]
command:
- |
echo "Creating demo user in Directus..."
sleep 5
# Check if demo user exists
EXISTING=$$(curl --globoff -s -H "Authorization: Bearer $${DIRECTUS_ADMIN_TOKEN}" \
"$${DIRECTUS_URL}/users?filter[email][_eq]=demo@synthstack.app")
if echo "$$EXISTING" | grep -q '"email":"demo@synthstack.app"'; then
echo "Demo user already exists"
exit 0
fi
# Get first role ID (Administrator is typically first)
ROLES_RESPONSE=$$(curl --globoff -s -H "Authorization: Bearer $${DIRECTUS_ADMIN_TOKEN}" "$${DIRECTUS_URL}/roles")
# Extract ID using sed - more reliable than grep for JSON
ROLE_ID=$$(echo "$$ROLES_RESPONSE" | sed 's/.*"id":"\([^"]*\)".*/\1/' | head -1)
if [ -z "$$ROLE_ID" ] || [ "$$ROLE_ID" = "$$ROLES_RESPONSE" ]; then
echo "Could not find role ID, trying alternate parse..."
ROLE_ID=$$(echo "$$ROLES_RESPONSE" | grep -oE '"id":"[a-f0-9-]{36}"' | head -1 | cut -d'"' -f4)
fi
echo "Using role: $$ROLE_ID"
if [ -z "$$ROLE_ID" ]; then
echo "ERROR: Could not determine role ID"
exit 1
fi
# Create demo user
RESULT=$$(curl -s -X POST \
--globoff \
-H "Authorization: Bearer $${DIRECTUS_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
"$${DIRECTUS_URL}/users" \
-d "{
\"email\": \"demo@synthstack.app\",
\"password\": \"DemoUser2024!\",
\"first_name\": \"Demo\",
\"last_name\": \"User\",
\"role\": \"$$ROLE_ID\",
\"status\": \"active\"
}")
echo "$$RESULT"
if echo "$$RESULT" | grep -q '"email":"demo@synthstack.app"'; then
echo ""
echo "Demo user created: demo@synthstack.app / DemoUser2024!"
else
echo ""
echo "Warning: Demo user creation may have failed. Check logs."
fi
restart: "no"
networks:
- synthstack
# ============================================
# Database Migrations (Runs after Directus creates its schema)
# ============================================
directus-migrate:
image: postgres:15-alpine
container_name: ${CONTAINER_PREFIX:-synthstack}-migrate
env_file:
- .env
environment:
PGHOST: postgres
PGPORT: 5432
PGDATABASE: ${DB_DATABASE:-synthstack}
PGUSER: ${DB_USER:-synthstack}
PGPASSWORD: ${DB_PASSWORD:-change-this-password}
depends_on:
directus:
condition: service_healthy
volumes:
- ./services/directus/migrations:/migrations:ro
entrypoint: [ "/bin/sh", "-c" ]
command:
- |
echo "Running SynthStack database migrations..."
echo "Waiting for Directus to initialize its schema..."
# Wait for Directus to create its tables (max 60 seconds)
for i in $$(seq 1 60); do
if psql -At -c "SELECT 1 FROM information_schema.tables WHERE table_name = 'directus_users' LIMIT 1;" | grep -q 1; then
echo "Directus schema ready!"
break
fi
echo "Waiting for Directus schema... ($$i/60)"
sleep 1
done
# Ensure migration tracking table exists
psql -v ON_ERROR_STOP=1 -c "CREATE TABLE IF NOT EXISTS synthstack_migrations (filename TEXT PRIMARY KEY, applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW());"
# Run each migration file once (in lexicographic order)
for f in /migrations/*.sql; do
if [ -f "$$f" ]; then
NAME=$$(basename "$$f")
APPLIED=$$(psql -At -c "SELECT 1 FROM synthstack_migrations WHERE filename = '$$NAME' LIMIT 1;")
if [ "$$APPLIED" = "1" ]; then
echo "Skipping already applied: $$NAME"
continue
fi
echo "Running migration: $$NAME"
psql -v ON_ERROR_STOP=1 -f "$$f"
psql -v ON_ERROR_STOP=1 -c "INSERT INTO synthstack_migrations (filename) VALUES ('$$NAME');"
fi
done
echo ""
echo "Migrations complete!"
echo "Tables created:"
psql -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name NOT LIKE 'directus_%' ORDER BY table_name LIMIT 30;"
restart: "no"
networks:
- synthstack
# ============================================
# API Gateway (Fastify + Node.js)
# ============================================
api-gateway:
build:
context: .
dockerfile: packages/api-gateway/Dockerfile.dev
container_name: ${CONTAINER_PREFIX:-synthstack}-api
ports:
- "3003:3003"
env_file:
- .env
environment:
NODE_ENV: development
PORT: 3003
HOST: 0.0.0.0
# Database
DATABASE_URL: postgresql://${DB_USER:-synthstack}:${DB_PASSWORD:-change-this-password}@postgres:5432/${DB_DATABASE:-synthstack}
# Directus
DIRECTUS_URL: http://directus:8055
DIRECTUS_TOKEN: ${DIRECTUS_ADMIN_TOKEN:-replace-with-secure-token}
# Supabase
SUPABASE_URL: ${SUPABASE_URL}
SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY}
SUPABASE_SERVICE_ROLE_KEY: ${SUPABASE_SERVICE_ROLE_KEY}
# ML Service (TypeScript)
ML_SERVICE_URL: http://ts-ml-service:8001
# Redis
REDIS_URL: redis://redis:6379
# Vector DB
QDRANT_URL: http://qdrant:6333
# CORS
CORS_ORIGIN: "http://localhost:3000,http://localhost:3050,http://localhost:5174,http://localhost:8099"
# Stripe
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
# AI
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
volumes:
- ./packages/api-gateway:/app/packages/api-gateway
- ./packages/types:/app/packages/types
- /app/node_modules
- /app/packages/api-gateway/node_modules
- ./docs:/docs:ro
depends_on:
directus:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
networks:
- synthstack
# ============================================
# ML Service (TypeScript/NestJS) - Community Edition
# Uses ts-ml-service instead of Python ml-service
# ============================================
ts-ml-service:
build:
context: .
dockerfile: packages/ts-ml-service/Dockerfile
container_name: ${CONTAINER_PREFIX:-synthstack}-ts-ml-service
ports:
- "8001:8001"
env_file:
- .env
environment:
NODE_ENV: development
PORT: 8001
# AI APIs
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
# Database (for RAG)
DATABASE_URL: postgresql://${DB_USER:-synthstack}:${DB_PASSWORD:-change-this-password}@postgres:5432/${DB_DATABASE:-synthstack}
# Redis
REDIS_URL: redis://redis:6379
# Vector DB
QDRANT_URL: http://qdrant:6333
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
networks:
- synthstack
# NOTE: django-ml-service and ml-service (Python) are Pro Edition only.
# Community Edition uses ts-ml-service (TypeScript) above.
# ============================================
# Web Frontend (Vue 3 + Quasar) - Development
# ============================================
web:
build:
context: ./apps/web
dockerfile: Dockerfile.dev
container_name: ${CONTAINER_PREFIX:-synthstack}-web
ports:
- "3050:3050"
env_file:
- .env
environment:
NODE_ENV: development
HOST: 0.0.0.0
PORT: 3050
CI: "true"
# API URLs
VITE_API_URL: http://localhost:3003
VITE_DIRECTUS_URL: http://localhost:8099
API_PROXY_TARGET: http://api-gateway:3003
DIRECTUS_PROXY_TARGET: http://directus:8055
# Supabase
VITE_SUPABASE_URL: ${SUPABASE_URL}
VITE_SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY}
# App Config
VITE_APP_NAME: SynthStack
VITE_APP_URL: http://localhost:3050
# Stripe
VITE_STRIPE_PUBLISHABLE_KEY: ${STRIPE_PUBLISHABLE_KEY}
volumes:
- ./apps/web:/app
- ./config.json:/config.json
- web_node_modules:/app/node_modules
command: [ "sh", "-c", "pnpm install --shamefully-hoist && pnpm dev" ]
depends_on:
- api-gateway
restart: unless-stopped
networks:
- synthstack
# ============================================
# Volumes
# ============================================
volumes:
postgres_data:
driver: local
redis_data:
driver: local
qdrant_data:
driver: local
directus_uploads:
driver: local
web_node_modules:
driver: local
# ============================================
# Networks
# ============================================
networks:
synthstack:
name: ${NETWORK_NAME:-synthstack-network}
driver: bridge
ipam:
config:
- subnet: 172.30.0.0/16