-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
executable file
·290 lines (276 loc) · 8.18 KB
/
Copy pathdocker-compose.yml
File metadata and controls
executable file
·290 lines (276 loc) · 8.18 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
x-project-name: &project-name ${COMPOSE_PROJECT_NAME:-projectx}
# Define common service settings to reduce duplication
x-service-common: &service-common
env_file: .env
networks:
- default
depends_on:
db:
condition: service_healthy
temporal:
condition: service_started
environment:
# Enable file system polling for better file watching in Docker
- WATCHPACK_POLLING=true
- CHOKIDAR_USEPOLLING=true
- CHOKIDAR_INTERVAL=500 # Faster interval for detecting changes
# Debugging and verbose logging
- DEBUG=turbo*
- FORCE_COLOR=1
# Turborepo cache dir inside the container
- TURBO_CACHE_DIR=/app/.turbo
- VITE_DEV_SERVER=true
- NODE_ENV=development
- NODE_OPTIONS=--max-old-space-size=4096
build:
context: .
dockerfile: Dockerfile
volumes:
# Mount the entire project directory to ensure all files are visible in the container
- .:/app:delegated
# These are anonymous volumes to prevent node_modules from being overwritten by host
- /app/node_modules
# Apps node_modules
- /app/apps/auth/node_modules
- /app/apps/order/node_modules
- /app/apps/product/node_modules
- /app/apps/web/node_modules
# Packages node_modules
- /app/packages/core/node_modules
- /app/packages/db/node_modules
- /app/packages/email/node_modules
- /app/packages/models/node_modules
- /app/packages/payment/node_modules
- /app/packages/ui/node_modules
- /app/packages/workflows/node_modules
# Frontend files that should not be watched (speeds up the container)
- /app/apps/web/.vite
- /app/apps/web/dist
services:
db:
image: postgis/postgis:17-3.5
platform: linux/amd64
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-db
restart: always
networks:
- default
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
PGDATA: /var/lib/postgresql/data/pgdata # Explicit PGDATA path
ports:
- "${POSTGRES_PORT:-5432}:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
start_period: 2s # Added start period
labels:
- "com.*project-name.service=database"
expose:
- "${POSTGRES_PORT:-5432}"
tmpfs:
- /tmp
- /run
- /run/postgresql
elasticsearch:
image: elasticsearch:7.17.27
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-elasticsearch
platform: linux/amd64
environment:
- cluster.routing.allocation.disk.threshold_enabled=true
- cluster.routing.allocation.disk.watermark.low=512mb
- cluster.routing.allocation.disk.watermark.high=256mb
- cluster.routing.allocation.disk.watermark.flood_stage=128mb
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms256m -Xmx256m
- xpack.security.enabled=false
networks:
- default
healthcheck:
test: [ "CMD-SHELL", "curl -f http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s || exit 1" ]
interval: 10s
timeout: 5s
retries: 10
labels:
- "com.*project-name.service=elasticsearch"
temporal-admin-tools:
image: temporalio/admin-tools:1.29.1-tctl-1.18.4-cli-1.5.0
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal-admin-tools
platform: linux/amd64
depends_on:
db:
condition: service_healthy
elasticsearch:
condition: service_healthy
environment:
- DB=postgres12
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PWD=${POSTGRES_PASSWORD}
- DB_HOST=db
- DB_PORT=${POSTGRES_PORT:-5432}
- SQL_PASSWORD=${POSTGRES_PASSWORD}
- ES_HOST=elasticsearch
- ES_PORT=9200
- ES_SCHEME=http
- ES_VERSION=v7
- ES_VISIBILITY_INDEX=temporal_visibility_v1_dev
networks:
- default
volumes:
- ./deployment/scripts/temporal:/scripts
entrypoint: [ "/bin/sh" ]
command: /scripts/setup-postgres-es.sh
temporal:
image: temporalio/server:1.29.2
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal
platform: linux/amd64
depends_on:
temporal-admin-tools:
condition: service_completed_successfully
environment:
- DB=postgres12
- DB_PORT=${POSTGRES_PORT:-5432}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PWD=${POSTGRES_PASSWORD}
- POSTGRES_SEEDS=db
- ENABLE_ES=true
- ES_SEEDS=elasticsearch
- ES_VERSION=v7
- BIND_ON_IP=0.0.0.0
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml
networks:
- default
volumes:
- ./deployment/config/dynamicconfig:/etc/temporal/config/dynamicconfig
ports:
- "${TEMPORAL_PORT:-7233}:7233"
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "7233" ]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
labels:
- "com.*project-name.service=temporal"
expose:
- "${TEMPORAL_PORT:-7233}"
temporal-create-namespace:
image: temporalio/admin-tools:1.29.1-tctl-1.18.4-cli-1.5.0
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal-create-namespace
platform: linux/amd64
depends_on:
temporal:
condition: service_healthy
environment:
- TEMPORAL_ADDRESS=temporal:${TEMPORAL_PORT:-7233}
- DEFAULT_NAMESPACE=${TEMPORAL_NAMESPACE:-default}
networks:
- default
volumes:
- ./deployment/scripts/temporal:/scripts
entrypoint: [ "/bin/sh" ]
command: /scripts/create-namespace.sh
temporal-ui:
image: temporalio/ui:2.44.1
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal-ui
platform: linux/amd64
depends_on:
temporal:
condition: service_healthy
environment:
- TEMPORAL_ADDRESS=temporal:${TEMPORAL_PORT:-7233}
- TEMPORAL_CORS_ORIGINS=http://localhost:3000
networks:
- default
ports:
- "${TEMPORAL_UI_PORT:-8080}:8080"
labels:
- "com.*project-name.service=temporal-ui"
expose:
- "${TEMPORAL_UI_PORT:-8080}"
# PROJECTX SERVICES
# Builder service - runs once to build all packages before app services start
builder:
<<: *service-common
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-builder
command:
- /bin/sh
- -c
- |
pnpm install --frozen-lockfile && \
pnpm turbo run build --filter=auth^... --filter=order^... --filter=product^... && \
pnpm --filter @projectx/db run prisma:migrate && \
pnpm --filter @projectx/db run prisma:seed && \
echo "Build complete!"
# No ports needed - this is a one-time build service
auth:
<<: *service-common
container_name: auth
init: true
depends_on:
builder:
condition: service_completed_successfully
command:
- /bin/sh
- -c
- |
cd /app/apps/auth && \
exec pnpm start:debug
ports:
- "${AUTH_PORT:-8081}:${AUTH_PORT:-8081}"
- "9229:9229"
order:
<<: *service-common
container_name: order
init: true
depends_on:
builder:
condition: service_completed_successfully
command:
- /bin/sh
- -c
- |
cd /app/apps/order && \
exec pnpm start:debug
ports:
- "${ORDER_PORT:-8082}:${ORDER_PORT:-8082}"
- "9230:9230"
product:
<<: *service-common
container_name: product
init: true
depends_on:
builder:
condition: service_completed_successfully
command:
- /bin/sh
- -c
- |
cd /app/apps/product && \
exec pnpm start:debug
ports:
- "${PRODUCT_PORT:-8083}:${PRODUCT_PORT:-8083}"
- "9231:9231"
ngrok-order:
image: ngrok/ngrok:latest
platform: linux/amd64
command:
- "http"
- "http://host.docker.internal:${ORDER_PORT:-8082}"
environment:
NGROK_AUTHTOKEN: ${NGROK_AUTHTOKEN}
ports:
- 4040:4040
networks:
default:
name: ${COMPOSE_PROJECT_NAME:-projectx}-network
driver: bridge
volumes:
postgres_data:
name: ${COMPOSE_PROJECT_NAME:-projectx}-postgres-data