-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
271 lines (260 loc) · 9.17 KB
/
docker-compose.dev.yml
File metadata and controls
271 lines (260 loc) · 9.17 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
# Storedog Development Environment
# This docker-compose file sets up a complete development environment for the Storedog application.
services:
# Datadog Agent for monitoring and observability
dd-agent:
image: gcr.io/datadoghq/agent:latest
pid: host
environment:
- DD_API_KEY=${DD_API_KEY}
- DD_ENV=${DD_ENV:-development}
- DD_LOGS_ENABLED=true
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
- DD_CONTAINER_EXCLUDE=image:agent name:puppeteer
- DD_CLOUD_PROVIDER_METADATA=[]
- DD_HOSTNAME=${DD_HOSTNAME-development-host}
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
networks:
- storedog-network
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
- postgres_logs:/var/log/pg_log:ro
# Frontend service (Next.js)
frontend:
build:
context: ./services/frontend
command: bash -c "wait-for-it backend:4000 -- ${FRONTEND_COMMAND:-npm run dev}"
depends_on:
- worker
- dd-agent
- backend
volumes:
- ./services/frontend:/app
- /app/node_modules
networks:
- storedog-network
environment:
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=store-frontend-api # used for Next.js API routes
- DD_VERSION=${NEXT_PUBLIC_DD_VERSION_FRONTEND-1.0.0}
- DD_RUNTIME_METRICS_ENABLED=true
- DD_PROFILING_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
- NEXT_PUBLIC_DD_APPLICATION_ID=${NEXT_PUBLIC_DD_APPLICATION_ID:-DD_APPLICATION_ID-not-set}
- NEXT_PUBLIC_DD_CLIENT_TOKEN=${NEXT_PUBLIC_DD_CLIENT_TOKEN:-DD_CLIENT_TOKEN-not-set}
- NEXT_PUBLIC_DD_SITE=${NEXT_PUBLIC_DD_SITE:-datadoghq.com}
- NEXT_PUBLIC_DD_SERVICE_FRONTEND=store-frontend # used for client-side Next.js RUM configuration
- NEXT_PUBLIC_DD_ENV=${DD_ENV:-development}
- NEXT_PUBLIC_ADS_ROUTE=${NEXT_PUBLIC_ADS_ROUTE:-/services/ads}
- NEXT_PUBLIC_DISCOUNTS_ROUTE=${NEXT_PUBLIC_DISCOUNTS_ROUTE:-/services/discounts}
- NEXT_PUBLIC_DBM_ROUTE=${NEXT_PUBLIC_DBM_ROUTE:-/services/dbm}
- NEXT_PUBLIC_FRONTEND_API_ROUTE=${NEXT_PUBLIC_FRONTEND_API_ROUTE:-http://localhost:3000}
- NEXT_PUBLIC_SPREE_API_HOST=${NEXT_PUBLIC_SPREE_API_HOST:-http://service-proxy/services/backend}
- NEXT_PUBLIC_SPREE_CLIENT_HOST=${NEXT_PUBLIC_SPREE_CLIENT_HOST:-/services/backend}
- NEXT_PUBLIC_SPREE_IMAGE_HOST=${NEXT_PUBLIC_SPREE_IMAGE_HOST:-/services/backend}
- NEXT_PUBLIC_SPREE_ALLOWED_IMAGE_DOMAIN=${NEXT_PUBLIC_SPREE_ALLOWED_IMAGE_DOMAIN:-service-proxy}
labels:
com.datadoghq.ad.logs: '[{"source": "nodejs", "auto_multi_line_detection": true }]'
# Backend service (Ruby on Rails/Spree)
backend:
build:
context: ./services/backend
command: wait-for-it postgres:5432 -- bundle exec ddprofrb exec rails s -b 0.0.0.0 -p 4000 --pid /app/tmp/pids/server.pid
depends_on:
- 'postgres'
- 'redis'
- 'dd-agent'
networks:
- storedog-network
volumes:
- './services/backend:/app'
environment:
- REDIS_URL=redis://redis:6379/0
- DB_HOST=postgres
- DB_PORT=5432
- POSTGRES_USER=${POSTGRES_USER-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD-postgres}
- DISABLE_SPRING=1
- RAILS_ENV=${RAILS_ENV:-production}
- DB_POOL=${DB_POOL:-25}
- MAX_THREADS=${MAX_THREADS:-5}
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=store-backend
- DD_VERSION=${DD_VERSION_BACKEND:-1.0.0}
- DD_RUNTIME_METRICS_ENABLED=true
- DD_PROFILING_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
labels:
com.datadoghq.ad.logs: '[{"source": "ruby", "auto_multi_line_detection": true }]'
# Background job processor (Sidekiq)
worker:
build:
context: ./services/backend
command: wait-for-it postgres:5432 -- bundle exec ddprofrb exec sidekiq -C config/sidekiq.yml
depends_on:
- 'postgres'
- 'redis'
- 'backend'
- 'dd-agent'
networks:
- storedog-network
volumes:
- ./services/backend:/app
environment:
# this will never not be true
- WORKER=true
- REDIS_URL=redis://redis:6379/0
- DB_HOST=postgres
- DB_PORT=5432
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- DISABLE_SPRING=1
- DB_POOL=${DB_POOL:-25}
- MAX_THREADS=${MAX_THREADS:-5}
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=store-worker
- DD_VERSION=${DD_VERSION_BACKEND:-1.0.0}
- DD_RUNTIME_METRICS_ENABLED=true
- DD_PROFILING_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
labels:
com.datadoghq.ad.logs: '[{"source": "ruby", "auto_multi_line_detection": true }]'
# Discounts service (Python/Flask)
discounts:
build:
context: ./services/discounts
command: wait-for-it postgres:5432 -- ddtrace-run flask run --port=2814 --host=0.0.0.0
depends_on:
- postgres
- dd-agent
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_HOST=postgres
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=store-discounts
- DD_VERSION=${DD_VERSION_DISCOUNTS:-1.0.0}
- DD_RUNTIME_METRICS_ENABLED=true
- DD_PROFILING_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
volumes:
- ./services/discounts:/app
networks:
- storedog-network
labels:
com.datadoghq.ad.logs: '[{"source": "python"}]'
# Advertisement service (Java)
ads:
build:
context: ./services/ads/java
depends_on:
- postgres
- dd-agent
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_HOST=postgres
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=store-ads
- DD_VERSION=${DD_VERSION_ADS:-1.0.0}
- DD_PROFILING_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
networks:
- storedog-network
labels:
com.datadoghq.ad.logs: '[{"source": "java"}]'
# Web server and reverse proxy
service-proxy:
build:
context: ./services/nginx
restart: always
ports:
- '80:80'
networks:
- storedog-network
depends_on:
- frontend
- dd-agent
environment:
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-development}
- DD_SERVICE=service-proxy
- DD_VERSION=${DD_VERSION_NGINX:-1.28.0}
labels:
com.datadoghq.ad.logs: '[{"source": "nginx"}]'
com.datadoghq.ad.check_names: '["nginx"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"nginx_status_url": "http://%%host%%:81/nginx_status/"}]'
# Primary database
postgres:
build:
context: ./services/postgres
restart: always
depends_on:
- dd-agent
volumes:
- postgres_logs:/var/log/pg_log:rw
networks:
- storedog-network
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
labels:
com.datadoghq.tags.service: 'store-db'
com.datadoghq.tags.version: '${DD_VERSION_POSTGRES:-15.0}'
com.datadoghq.ad.check_names: '["postgres"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host":"%%host%%", "port":5432, "username":"datadog", "password":"datadog"}]'
com.datadoghq.ad.logs: '[{"source": "postgresql", "service":"store-db", "auto_multi_line_detection": true, "path": "/var/log/pg_log/postgresql*.json", "type": "file"}]'
# Cache and job queue
redis:
image: redis:6.2-alpine
depends_on:
- dd-agent
volumes:
- 'redis:/data'
networks:
- storedog-network
labels:
com.datadoghq.tags.service: 'redis'
com.datadoghq.tags.version: '${DD_VERSION_REDIS:-6.2}'
com.datadoghq.ad.check_names: '["redisdb"]'
com.datadoghq.ad.init_configs: '[{}]'
com.datadoghq.ad.instances: '[{"host":"%%host%%", "port":6379}]'
com.datadoghq.ad.logs: '[{"source": "redis"}]'
# Browser automation for testing
puppeteer:
build:
context: ./services/puppeteer
platform: linux/amd64
environment:
- STOREDOG_URL=${STOREDOG_URL:-http://service-proxy:80}
- PUPPETEER_TIMEOUT=${PUPPETEER_TIMEOUT:-30000}
- SKIP_SESSION_CLOSE=${SKIP_SESSION_CLOSE:-false}
networks:
- storedog-network
volumes:
- ./services/puppeteer/scripts/puppeteer.js:/home/pptruser/puppeteer.js
depends_on:
- frontend
shm_size: '4gb' # Increase shared memory size
cap_add:
- 'SYS_ADMIN' # Required for Puppeteer to run in Docker
volumes:
redis: # Redis data persistence
postgres_logs: # PostgreSQL logs storage
networks:
storedog-network: # Main application network