-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
299 lines (284 loc) · 8.82 KB
/
docker-compose.yml
File metadata and controls
299 lines (284 loc) · 8.82 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
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_USER: dispatch
POSTGRES_PASSWORD: dispatch
POSTGRES_DB: dispatch
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U dispatch']
interval: 5s
timeout: 3s
retries: 5
redis:
image: redis:7-alpine
ports:
- '6379:6379'
volumes:
- redisdata:/data
rabbitmq:
image: rabbitmq:3-management-alpine
ports:
- '5672:5672'
- '15672:15672'
healthcheck:
test: ['CMD', 'rabbitmq-diagnostics', '-q', 'check_port_connectivity']
interval: 10s
timeout: 5s
retries: 5
users:
build:
context: .
dockerfile: services/users/Dockerfile
environment:
- PORT=4001
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=users
- JWT_SECRET=dev-secret
- NODE_ENV=development
- REDIS_URL=redis://redis:6379
depends_on:
postgres:
condition: service_healthy
ports:
- '14001:4001'
command: sh -c "pnpm -C services/users exec prisma migrate deploy; pnpm -C services/users exec prisma db push; node services/users/dist/services/users/src/main.js"
orders:
build:
context: .
dockerfile: services/orders/Dockerfile
environment:
- PORT=4002
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=orders
- JWT_SECRET=dev-secret
- NODE_ENV=development
- RABBITMQ_URL=amqp://rabbitmq:5672
- REDIS_URL=redis://redis:6379
- RULES_URL=http://rules:4004
- LABELS_BUCKET=dispatch-labels
- S3_ENDPOINT=http://minio:9000
- S3_PUBLIC_URL=http://localhost:9000
- S3_REGION=us-east-1
- S3_ACCESS_KEY_ID=minio
- S3_SECRET_ACCESS_KEY=minio123
- S3_FORCE_PATH_STYLE=true
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
minio:
condition: service_started
ports:
- '14002:4002'
command: sh -c "pnpm -C services/orders exec prisma migrate deploy || pnpm -C services/orders exec prisma db push; node services/orders/dist/main.js"
api-gateway:
build:
context: .
dockerfile: apps/api-gateway/Dockerfile
environment:
- PORT=3000
- USERS_URL=http://users:4001
- ORDERS_URL=http://orders:4002
- WEBHOOKS_URL=http://webhooks:4003
- NOTIFICATIONS_URL=http://notifications:4006
- CLICKHOUSE_URL=http://clickhouse:8123
- CLICKHOUSE_USER=default
- CLICKHOUSE_PASSWORD=
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch
- JWT_SECRET=dev-secret
- NODE_ENV=development
- REDIS_URL=redis://redis:6379
depends_on:
users:
condition: service_started
orders:
condition: service_started
notifications:
condition: service_started
ports:
- '3000:3000'
healthcheck:
test:
[
'CMD-SHELL',
"curl -s -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '{\"query\":\"{ health }\"}' | grep -q \"\\\"ok\\\"\"",
]
interval: 10s
timeout: 5s
retries: 5
webhooks:
build:
context: .
dockerfile: services/webhooks/Dockerfile
environment:
- PORT=4003
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=webhooks
- JWT_SECRET=dev-secret
- NODE_ENV=development
- RABBITMQ_URL=amqp://rabbitmq:5672
- REDIS_URL=redis://redis:6379
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
ports:
- '14003:4003'
# Ensure schema exists when there are no migrations: run db push in that case
command: sh -c "if [ -d services/webhooks/prisma/migrations ] && [ \"$(ls -A services/webhooks/prisma/migrations 2>/dev/null)\" ]; then pnpm -C services/webhooks exec prisma migrate deploy; else pnpm -C services/webhooks exec prisma db push; fi; node services/webhooks/dist/main.js"
healthcheck:
test: ['CMD', 'wget', '-qO-', 'http://localhost:4003/health']
interval: 5s
timeout: 3s
retries: 5
rules:
build:
context: .
dockerfile: services/rules/Dockerfile
environment:
- PORT=4004
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=rules
- JWT_SECRET=dev-secret
- NODE_ENV=development
- RABBITMQ_URL=amqp://rabbitmq:5672
- ORDERS_URL=http://orders:4002
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
ports:
- '14004:4004'
command: sh -c "pnpm -C services/rules exec prisma migrate deploy || pnpm -C services/rules exec prisma db push; node services/rules/dist/main.js"
healthcheck:
test: ['CMD', 'wget', '-qO-', 'http://localhost:4004/health']
interval: 5s
timeout: 3s
retries: 5
shopify:
build:
context: .
dockerfile: services/shopify/Dockerfile
environment:
- PORT=4005
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=shopify
- JWT_SECRET=dev-secret
- NODE_ENV=development
- ORDERS_URL=http://orders:4002
- SHOPIFY_APP_URL=http://localhost:14005
- SHOPIFY_API_KEY=your_api_key_here
- SHOPIFY_API_SECRET=your_api_secret_here
- SHOPIFY_SCOPES=read_orders
- SHOPIFY_API_VERSION=2024-07
depends_on:
postgres:
condition: service_healthy
ports:
- '14005:4005'
command: sh -c "pnpm -C services/shopify exec prisma migrate deploy || pnpm -C services/shopify exec prisma db push; node services/shopify/dist/main.js"
healthcheck:
test: ['CMD', 'wget', '-qO-', 'http://localhost:4005/health']
interval: 5s
timeout: 3s
retries: 5
notifications:
build:
context: .
dockerfile: services/notifications/Dockerfile
environment:
- PORT=4006
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch?schema=notifications
- JWT_SECRET=dev-secret
- NODE_ENV=development
- EMAIL_PROVIDER=noop
- EMAIL_FROM=no-reply@dispatch.local
- POSTMARK_TOKEN=
- SENDGRID_API_KEY=
- TWILIO_ACCOUNT_SID=
- TWILIO_AUTH_TOKEN=
- TWILIO_FROM_NUMBER=
depends_on:
postgres:
condition: service_healthy
ports:
- '14006:4006'
command: sh -c "pnpm -C services/notifications exec prisma migrate deploy || pnpm -C services/notifications exec prisma db push; node services/notifications/dist/main.js"
# Analytics database for slice 14
clickhouse:
image: clickhouse/clickhouse-server:23.8
environment:
CLICKHOUSE_DB: analytics
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: '1'
ports:
- '8123:8123' # HTTP
volumes:
- chdata:/var/lib/clickhouse
# One-off init to apply schema (runs client against ClickHouse)
clickhouse-init:
image: clickhouse/clickhouse-server:23.8
depends_on:
- clickhouse
volumes:
- ./docs/slices/14-analytics/contracts/clickhouse.sql:/schema/clickhouse.sql:ro
entrypoint: ['/bin/sh', '-lc']
command: |
"until clickhouse-client --host clickhouse -q 'SELECT 1'; do echo waiting for clickhouse; sleep 1; done; \
clickhouse-client --host clickhouse -n < /schema/clickhouse.sql; echo 'analytics schema applied'"
analytics:
build:
context: .
dockerfile: services/analytics/Dockerfile
environment:
- PORT=4007
- NODE_ENV=development
- RABBITMQ_URL=amqp://rabbitmq:5672
- CLICKHOUSE_URL=http://clickhouse:8123
- CLICKHOUSE_USER=default
- CLICKHOUSE_PASSWORD=
- DATABASE_URL=postgresql://dispatch:dispatch@postgres:5432/dispatch
- ETL_SPOOL_DIR=/var/spool/analytics
depends_on:
rabbitmq:
condition: service_healthy
clickhouse:
condition: service_started
clickhouse-init:
condition: service_completed_successfully
ports:
- '14007:4007'
command: sh -c "node services/analytics/dist/main.js"
volumes:
- analytics_spool:/var/spool/analytics
merchant-dashboard:
build:
context: .
dockerfile: apps/merchant-dashboard/Dockerfile
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=http://localhost:3000/graphql
depends_on:
api-gateway:
condition: service_started
ports:
- '3001:3001'
minio:
image: minio/minio:latest
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
command: server /data --console-address ":9001"
ports:
- '9000:9000'
- '9001:9001'
volumes:
- miniodata:/data
volumes:
pgdata: {}
redisdata: {}
miniodata: {}
chdata: {}
analytics_spool: {}