-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
306 lines (296 loc) · 9.9 KB
/
docker-compose.dev.yml
File metadata and controls
306 lines (296 loc) · 9.9 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
x-app-service-template: &app-service-defaults
build:
context: .
dockerfile: docker/Dockerfile.dev
args:
- API_CLOUD_MODE=${API_CLOUD_MODE:-false}
env_file:
- ${ENV_FILE:-.env}
environment:
- CHOKIDAR_USEPOLLING=false
- API_DEVELOPMENT_MODE=${API_DEVELOPMENT_MODE:-true}
restart: unless-stopped
volumes:
- .:/usr/src/app:delegated
- node_modules_cache:/usr/src/app/node_modules
- yalc_store:/root/.yalc
networks:
- kodus-backend-services
- shared-network
services:
#----------------------------------------------------------------
# Application Services
#----------------------------------------------------------------
kodus-api:
<<: *app-service-defaults
container_name: kodus_api
ports:
- '${API_PORT:-3001}:${API_PORT:-3001}'
- '9229:9229'
- '8000:8000'
command: yarn start:dev:api
deploy:
resources:
limits:
memory: 1.5G
reservations:
memory: 512M
healthcheck:
test:
[
'CMD-SHELL',
'node -e "const http=require(''http''); const port=process.env.API_PORT||3001; const req=http.get({host:''127.0.0.1'', port, path:''/health'', timeout:2000}, (res)=>process.exit(res.statusCode===200?0:1)); req.on(''error'', ()=>process.exit(1)); req.on(''timeout'', ()=>{ req.destroy(); process.exit(1); });"',
]
interval: 20s
timeout: 10s
retries: 8
start_period: 180s
environment:
- API_CLOUD_MODE=${API_CLOUD_MODE:-false}
- NODE_OPTIONS=--max-old-space-size=1200 --max-semi-space-size=64
- DEBUG_PORT=9229
- API_LOG_PRETTY=true
- CHOKIDAR_USEPOLLING=false
- API_DEVELOPMENT_MODE=${API_DEVELOPMENT_MODE:-true}
- RUN_MIGRATIONS=${RUN_MIGRATIONS:-true}
- RUN_SEEDS=${RUN_SEEDS:-true}
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_HEAP_PROFILING=${PYROSCOPE_HEAP_PROFILING:-false}
worker:
<<: *app-service-defaults
container_name: kodus_worker
volumes:
- .:/usr/src/app:delegated
- node_modules_cache:/usr/src/app/node_modules:nocopy
- yalc_store:/root/.yalc
ports:
- '9231:9231'
- '8001:8001'
command: yarn start:dev:worker
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
healthcheck:
test: ['CMD', 'node', '-e', 'process.exit(0)']
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
environment:
- API_CLOUD_MODE=${API_CLOUD_MODE:-false}
- NODE_OPTIONS=--max-semi-space-size=64
- DEBUG_PORT=9231
- COMPONENT_TYPE=worker
- API_LOG_PRETTY=true
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_HEAP_PROFILING=${PYROSCOPE_HEAP_PROFILING:-false}
webhooks:
<<: *app-service-defaults
container_name: kodus_webhooks
volumes:
- .:/usr/src/app:delegated
- node_modules_cache:/usr/src/app/node_modules:nocopy
- yalc_store:/root/.yalc
ports:
- '${API_WEBHOOKS_PORT:-3332}:${API_WEBHOOKS_PORT:-3332}'
- '9232:9232'
- '8002:8002'
command: yarn start:dev:webhooks
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 256M
healthcheck:
test: ['CMD', 'node', '-e', 'process.exit(0)']
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
environment:
- API_CLOUD_MODE=${API_CLOUD_MODE:-false}
- NODE_OPTIONS=--max-semi-space-size=64
- DEBUG_PORT=9232
- API_LOG_PRETTY=true
- PYROSCOPE_SERVER_ADDRESS=${PYROSCOPE_SERVER_ADDRESS:-http://pyroscope:4040}
- PYROSCOPE_HEAP_PROFILING=${PYROSCOPE_HEAP_PROFILING:-false}
#----------------------------------------------------------------
# Web Frontend
#----------------------------------------------------------------
web:
build:
context: ./apps/web
dockerfile: ../../docker/Dockerfile.web.dev
container_name: kodus_web
depends_on:
kodus-api:
condition: service_healthy
ports:
- '${WEB_PORT:-3000}:3000'
env_file:
- ${ENV_FILE:-.env}
volumes:
- ./apps/web:/usr/src/app:delegated
- web_node_modules_cache:/usr/src/app/node_modules
- web_next_cache:/usr/src/app/.next
- yalc_store:/root/.yalc
restart: unless-stopped
healthcheck:
test:
[
'CMD',
'node',
'-e',
"fetch('http://localhost:3000').then((res)=>process.exit(res.ok?0:1)).catch(()=>process.exit(1))",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
networks:
- kodus-backend-services
- shared-network
environment:
- CHOKIDAR_USEPOLLING=false
- NODE_ENV=development
- NEXT_TELEMETRY_DISABLED=1
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
#----------------------------------------------------------------
# Observability & Profiling
#----------------------------------------------------------------
pyroscope:
profiles:
- profiling
- infra
image: docker.io/grafana/pyroscope:latest
container_name: pyroscope
ports:
- '4040:4040'
volumes:
- pyroscope-data:/var/lib/pyroscope
networks:
- kodus-backend-services
restart: unless-stopped
#----------------------------------------------------------------
# Databases & Infrastructure
#----------------------------------------------------------------
rabbitmq:
profiles:
- local-db
- infra
build:
context: ./docker/rabbitMQ
dockerfile: Dockerfile
container_name: rabbitmq
hostname: ${RABBITMQ_HOSTNAME:-rabbitmq-local}
ports:
- '5672:5672'
- '15672:15672'
- '15692:15692'
volumes:
- rabbitmq-data:/var/lib/rabbitmq
restart: unless-stopped
networks:
kodus-backend-services:
aliases:
- rabbitmq-local
- rabbitmq
shared-network:
aliases:
- rabbitmq-local
- rabbitmq
healthcheck:
test: ['CMD', 'rabbitmq-diagnostics', '-q', 'check_running']
interval: 30s
timeout: 10s
retries: 5
ulimits:
nofile:
soft: 65536
hard: 65536
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER:-dev}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-devpass}
RABBITMQ_HOSTNAME: ${RABBITMQ_HOSTNAME:-rabbitmq}
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '-rabbit heartbeat 60'
command: /usr/local/bin/init-definitions.sh
db_postgres:
profiles:
- local-db
- infra
image: docker.io/pgvector/pgvector:pg16
container_name: db_postgres
ports:
- '5432:5432'
environment:
POSTGRES_USER: ${API_PG_DB_USERNAME}
POSTGRES_PASSWORD: ${API_PG_DB_PASSWORD}
POSTGRES_DB: ${API_PG_DB_DATABASE}
volumes:
- pgdata:/var/lib/postgresql/data
- ./docker/postgres/initdb.d:/docker-entrypoint-initdb.d
networks:
- kodus-backend-services
restart: unless-stopped
healthcheck:
test:
[
'CMD-SHELL',
'pg_isready -U ${API_PG_DB_USERNAME} -d ${API_PG_DB_DATABASE}',
]
interval: 5s
timeout: 3s
retries: 20
start_period: 10s
db_mongodb:
profiles:
- local-db
- infra
image: docker.io/mongo:8
container_name: mongodb
ports:
- '27017:27017'
volumes:
- mongodbdata:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: ${API_MG_DB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${API_MG_DB_PASSWORD}
MONGO_INITDB_DATABASE: ${API_MG_DB_DATABASE}
networks:
- kodus-backend-services
restart: unless-stopped
healthcheck:
test:
[
'CMD-SHELL',
"echo 'db.runCommand({ ping: 1 }).ok' | mongosh --quiet mongodb://$${MONGO_INITDB_ROOT_USERNAME}:$${MONGO_INITDB_ROOT_PASSWORD}@localhost:27017/admin | grep -q 1",
]
interval: 10s
timeout: 5s
retries: 20
start_period: 20s
volumes:
yalc_store:
node_modules_cache:
web_node_modules_cache:
web_next_cache:
pgdata:
mongodbdata:
pyroscope-data:
rabbitmq-data:
networks:
kodus-backend-services:
driver: bridge
name: kodus-backend-services
external: true
shared-network:
external: true