Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
executable file
·256 lines (244 loc) · 7.89 KB
/
Copy pathdocker-compose.yml
File metadata and controls
executable file
·256 lines (244 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
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
x-project-name: &project-name ${COMPOSE_PROJECT_NAME:-projectx}
# Define common service settings to reduce duplication
x-service-common: &service-common
env_file:
# cp .env.example .env
- path: .env
required: false
networks:
- default
depends_on:
db:
condition: service_healthy
temporal:
condition: service_healthy
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
- NODE_ENV=development
- NODE_OPTIONS=--max-old-space-size=4096
# Inside the network the services are reached by name, whatever .env says for local runs
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public&connect_timeout=300
- TEMPORAL_HOST=temporal:7233
# The API always listens on 8081 in its container; API_PORT only picks the host port
- API_PORT=8081
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/api/node_modules
# Packages node_modules
- /app/packages/cli/node_modules
- /app/packages/core/node_modules
- /app/packages/db/node_modules
- /app/packages/email/node_modules
- /app/packages/models/node_modules
services:
db:
image: postgis/postgis:17-3.6
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:
# Over TCP: the init scripts run against a socket-only server, so the socket alone reports ready too early
test: [ "CMD-SHELL", "pg_isready -h 127.0.0.1 -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
start_period: 2s # Added start period
labels:
- "com.*project-name.service=database"
tmpfs:
- /tmp
- /run
- /run/postgresql
elasticsearch:
image: elasticsearch:7.17.28
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
volumes:
# Custom search attribute mappings only live in the index, Temporal will not recreate them if this is lost
- elasticsearch_data:/usr/share/elasticsearch/data
healthcheck:
test: [ "CMD-SHELL", "curl -sf '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.32.1
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=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.32.1
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal
platform: linux/amd64
depends_on:
temporal-admin-tools:
condition: service_completed_successfully
environment:
- DB=postgres12
- DB_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"
temporal-create-namespace:
image: temporalio/admin-tools:1.32.1
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal-create-namespace
platform: linux/amd64
depends_on:
temporal:
condition: service_healthy
environment:
- TEMPORAL_ADDRESS=temporal:7233
- TEMPORAL_NAMESPACE=${TEMPORAL_NAMESPACE:-default}
- TEMPORAL_NAMESPACE_RETENTION=${TEMPORAL_NAMESPACE_RETENTION:-72h}
- TEMPORAL_SEARCH_ATTRIBUTES=${TEMPORAL_SEARCH_ATTRIBUTES:-}
networks:
- default
volumes:
- ./deployment/scripts/temporal:/scripts
entrypoint: [ "/bin/sh" ]
command: /scripts/create-namespace.sh
temporal-ui:
image: temporalio/ui:2.57.0
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-temporal-ui
platform: linux/amd64
depends_on:
temporal:
condition: service_healthy
environment:
- TEMPORAL_ADDRESS=temporal:7233
networks:
- default
ports:
- "${TEMPORAL_UI_PORT:-8080}:8080"
labels:
- "com.*project-name.service=temporal-ui"
# PROJECTX SERVICES
# Builder service - runs once to install, build the api's dependencies, migrate and seed
builder:
<<: *service-common
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-builder
depends_on:
db:
condition: service_healthy
command:
- /bin/sh
- -c
- |
pnpm install --frozen-lockfile && \
pnpm --filter @projectx/db run prisma:generate && \
pnpm turbo run build --filter=@projectx/api^... && \
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
api:
<<: *service-common
container_name: ${COMPOSE_PROJECT_NAME:-projectx}-api
init: true
depends_on:
db:
condition: service_healthy
builder:
condition: service_completed_successfully
# The namespace and its search attributes must exist before the worker starts
temporal-create-namespace:
condition: service_completed_successfully
command:
- /bin/sh
- -c
- |
cd /app/apps/api && \
exec pnpm start:debug
ports:
- "${API_PORT:-8081}:8081"
- "${API_DEBUG_PORT:-9229}:9229"
labels:
- "com.*project-name.service=api"
networks:
default:
name: ${COMPOSE_PROJECT_NAME:-projectx}-network
driver: bridge
volumes:
elasticsearch_data:
postgres_data:
name: ${COMPOSE_PROJECT_NAME:-projectx}-postgres-data