Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
226 lines (213 loc) · 7.89 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
226 lines (213 loc) · 7.89 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
# ============================================================
# Docker Compose — Local development (one-command spin-up)
# ============================================================
# Starts the full stack: postgres + redis + minio + web + worker,
# creates the MinIO bucket and runs Prisma migrations automatically.
#
# Usage:
# cp .env.dev.example .env.dev # first time only
# # edit .env.dev and add ANTHROPIC_API_KEY (required)
# docker compose -f docker-compose.dev.yml --env-file .env.dev up -d --build
#
# Then open http://localhost:3001 — click "Dev login" to sign in
# with any email (no password, no SMTP).
#
# Shut down:
# docker compose -f docker-compose.dev.yml down
#
# Reset everything (drops DB + storage):
# docker compose -f docker-compose.dev.yml down -v
# ============================================================
services:
# ──────────────────────────────────────────────────────────
# Infrastructure
# ──────────────────────────────────────────────────────────
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- '${POSTGRES_PORT}:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD}
ports:
- '${REDIS_PORT}:6379'
volumes:
- redis_data:/data
healthcheck:
test: ['CMD', 'redis-cli', '-a', '${REDIS_PASSWORD}', 'ping']
interval: 5s
timeout: 5s
retries: 10
# n8n — used by the n8n-explainer module to load workflow JSON and take
# screenshots. Running it as a compose service lets the worker talk to it
# over HTTP instead of spawning a sibling docker container from inside
# itself (which would need Docker-in-Docker).
n8n:
image: n8nio/n8n:latest
environment:
N8N_DIAGNOSTICS_ENABLED: 'false'
N8N_TEMPLATES_ENABLED: 'false'
N8N_PERSONALIZATION_ENABLED: 'false'
N8N_VERSION_NOTIFICATIONS_ENABLED: 'false'
N8N_SECURE_COOKIE: 'false'
ports:
- '5678:5678'
volumes:
- n8n_data:/home/node/.n8n
healthcheck:
test: ['CMD-SHELL', 'wget -q -O - http://localhost:5678/healthz || exit 1']
interval: 10s
timeout: 5s
retries: 20
minio:
image: minio/minio
command: server /data --console-address ":9001"
ports:
- '${MINIO_PORT}:9000'
- '${MINIO_CONSOLE_PORT}:9001'
environment:
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
volumes:
- minio_data:/data
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live']
interval: 10s
timeout: 5s
retries: 10
# ──────────────────────────────────────────────────────────
# One-shot setup containers
# ──────────────────────────────────────────────────────────
# Create the MinIO bucket and make it publicly readable for rendered videos.
minio-setup:
image: minio/mc
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
mc alias set local http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY} &&
mc mb --ignore-existing local/${MINIO_BUCKET} &&
mc anonymous set download local/${MINIO_BUCKET} &&
echo 'MinIO bucket ${MINIO_BUCKET} ready.'
"
restart: 'no'
# Apply the Prisma schema to the dev database (idempotent).
db-migrate:
build:
context: .
dockerfile: docker/Dockerfile.dev
depends_on:
postgres:
condition: service_healthy
command: >
sh -c "
bunx prisma db push --schema=packages/database/prisma/schema.prisma --accept-data-loss &&
bun run scripts/seed-modules.ts &&
echo 'Database schema + module catalog ready.'
"
env_file: .env.dev
environment:
DATABASE_URL: ${DATABASE_URL}
volumes:
# Reuse the same named node_modules volumes as web + worker so prisma
# generate lands in one place everything can import from.
- .:/app
- node_modules_root:/app/node_modules
- node_modules_web:/app/apps/web/node_modules
restart: 'no'
# ──────────────────────────────────────────────────────────
# Application services (hot reload via mounted source)
# ──────────────────────────────────────────────────────────
web:
build:
context: .
dockerfile: docker/Dockerfile.dev
command: bun --cwd apps/web dev -- --hostname 0.0.0.0 --port 3000
env_file: .env.dev
environment:
# Override the host ports with in-network service names
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
MINIO_ENDPOINT: ${MINIO_ENDPOINT}
MINIO_PORT: '9000'
ports:
- '3001:3000'
volumes:
# Mount source for hot reload. node_modules are named volumes shared
# with the worker service — one `bun install` from the Dockerfile
# populates them, both services see the same Linux binaries.
- .:/app
- node_modules_root:/app/node_modules
- node_modules_web:/app/apps/web/node_modules
- next_cache:/app/apps/web/.next
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
minio-setup:
condition: service_completed_successfully
db-migrate:
condition: service_completed_successfully
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3000/api/health']
interval: 10s
timeout: 5s
retries: 20
worker:
build:
context: .
dockerfile: docker/Dockerfile.dev
command: bun --cwd apps/web worker
# Chrome-headless-shell (Remotion + Hyperframes) allocates shared
# memory per rendering worker. Default docker shm is 64 MB which
# crashes Chrome under multi-worker parallel capture. 512 MB gives
# plenty of headroom without bloating the container.
shm_size: 512m
env_file: .env.dev
environment:
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
MINIO_ENDPOINT: ${MINIO_ENDPOINT}
MINIO_PORT: '9000'
# Presigned URLs need to be reachable from the host (where the browser
# lives), not just from inside the docker network. Operator points
# this at wherever MinIO is exposed to clients.
MINIO_PUBLIC_ENDPOINT: localhost
# Point n8n-explainer at the sibling n8n service so it doesn't try to
# `docker run` from inside this container.
N8N_BASE_URL: http://n8n:5678
volumes:
- .:/app
- node_modules_root:/app/node_modules
- node_modules_web:/app/apps/web/node_modules
depends_on:
web:
condition: service_healthy
n8n:
condition: service_healthy
# Same node_modules volumes are also needed by db-migrate so the seed can
# import prisma + the workspace packages.
# (already referenced above — listed here for the volumes: section below)
volumes:
postgres_data:
redis_data:
minio_data:
n8n_data:
node_modules_root:
node_modules_web:
next_cache: