-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
294 lines (285 loc) · 7.51 KB
/
docker-compose.yml
File metadata and controls
294 lines (285 loc) · 7.51 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
---
networks:
bt:
services:
backend:
build:
context: .
dockerfile: ./apps/backend/Dockerfile
target: backend-dev
depends_on:
mongodb:
condition: service_healthy
redis:
condition: service_started
redis-preflight:
condition: service_completed_successfully
networks:
- bt
restart: always
healthcheck:
test:
- CMD
- node
- -e
- require("http").get("http://localhost:5001/api/graphql",()=>process.exit(0)).on("error",()=>process.exit(1))
interval: 5s
timeout: 5s
start_period: 20s
retries: 20
volumes:
- ./.env:/backend/apps/backend/.env
- ./apps/backend:/backend/apps/backend
- ./packages:/backend/packages
semantic-search:
profiles:
- semantic-search
build:
context: ./apps/semantic-search
dockerfile: Dockerfile
networks:
- bt
ports:
- "${DEV_PORT_PREFIX:-30}10:8000"
restart: always
volumes:
- ./apps/semantic-search/app:/app/app
environment:
- SEMANTIC_SEARCH_YEAR=2026
- SEMANTIC_SEARCH_SEMESTER=Spring
- BACKEND_URL=http://backend:5001
- REDIS_URI=redis://redis:6379
frontend:
build:
context: .
dockerfile: ./apps/frontend/Dockerfile
target: frontend-dev
networks:
- bt
restart: always
volumes:
- ./apps/frontend:/frontend/apps/frontend
- ./packages:/frontend/packages
ag-frontend:
profiles:
- ag
build:
context: .
dockerfile: ./apps/ag-frontend/Dockerfile
target: ag-frontend-dev
networks:
- bt
restart: always
volumes:
- ./apps/ag-frontend:/ag-frontend/apps/ag-frontend
- ./packages:/ag-frontend/packages
staff-frontend:
profiles:
- staff
build:
context: .
dockerfile: ./apps/staff-frontend/Dockerfile
target: staff-frontend-dev
networks:
- bt
restart: always
volumes:
- ./apps/staff-frontend:/staff-frontend/apps/staff-frontend
- ./packages:/staff-frontend/packages
mongodb-preflight:
image: alpine:3.22
networks:
- bt
restart: "no"
entrypoint:
- /bin/sh
command:
- -ec
- |
mkdir -p /data/db /data/configdb
# Ensure mongod can read/write persisted paths across host OSes.
chown -R 1000:1000 /data/db /data/configdb || true
chmod 700 /data/configdb || true
# Recover from an interrupted bootstrap where lock files exist but
# WiredTiger metadata was never fully initialized.
if [ -f /data/db/WiredTiger.lock ] && [ ! -f /data/db/WiredTiger ]; then
echo "Detected incomplete WiredTiger state. Resetting /data/db."
rm -rf /data/db/*
fi
rm -f /data/db/mongod.lock || true
# Let Atlas local create/rotate its own keyfile, but clear obviously
# invalid leftovers so startup can recover.
if [ -f /data/configdb/keyfile ] && ( [ ! -s /data/configdb/keyfile ] || ! tr -d '\r\n' < /data/configdb/keyfile | grep -Eq '^[A-Za-z0-9+/=][A-Za-z0-9+/=]*$' ); then
echo "Removing invalid MongoDB keyfile."
rm -f /data/configdb/keyfile
fi
# On first boot, seed a valid keyfile so Atlas local can start even
# when /data/configdb is an empty mounted volume.
if [ ! -f /data/configdb/keyfile ]; then
echo "Generating MongoDB keyfile for fresh volume."
head -c 756 /dev/urandom | base64 | tr -d '\n' > /data/configdb/keyfile
fi
if [ -f /data/configdb/keyfile ]; then
chmod 600 /data/configdb/keyfile || true
chown 1000:1000 /data/configdb/keyfile || true
fi
volumes:
- mongodb-db:/data/db
- mongodb-configdb:/data/configdb
mongodb:
image: mongodb/mongodb-atlas-local:8.0
hostname: rs0
depends_on:
mongodb-preflight:
condition: service_completed_successfully
networks:
- bt
ports:
- "${DEV_PORT_PREFIX:-30}08:27017"
healthcheck:
test: '/usr/bin/mongosh --port 27017 --quiet --eval "db.runCommand({ ping: 1 }).ok"'
interval: 5s
timeout: 10s
start_period: 15s
retries: 10
volumes:
- mongodb-db:/data/db
- mongodb-configdb:/data/configdb
- ./infra/mongo/migrations:/migrations
mongodb-init:
image: mongodb/mongodb-atlas-local:8.0
depends_on:
mongodb:
condition: service_healthy
networks:
- bt
restart: "no"
entrypoint:
- /bin/sh
command:
- -ec
- |
attempts=0
until mongosh "mongodb://mongodb:27017/bt" /scripts/01-create-search-indexes.js; do
attempts=$$((attempts + 1))
if [ "$$attempts" -ge 30 ]; then
echo "mongodb-init failed after $$attempts attempts."
exit 1
fi
echo "mongodb-init retry $$attempts/30..."
sleep 2
done
volumes:
- ./docker/mongodb/init:/scripts:ro
nginx:
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_started
image: nginx:1.21
networks:
- bt
ports:
- "${DEV_PORT_PREFIX:-30}00:8080"
- "${DEV_PORT_PREFIX:-30}01:8081"
- "${DEV_PORT_PREFIX:-30}02:8082"
restart: always
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
redis:
image: redis/redis-stack-server:7.2.0-v14
ports:
- "${DEV_PORT_PREFIX:-30}04:6379"
networks:
- bt
restart: always
redis-preflight:
image: redis/redis-stack-server:7.2.0-v14
depends_on:
redis:
condition: service_started
networks:
- bt
restart: "no"
entrypoint:
- /bin/sh
command:
- -ec
- |
attempts=0
until [ "$$(redis-cli -h redis ping)" = "PONG" ]; do
attempts=$$((attempts + 1))
if [ "$$attempts" -ge 30 ]; then
echo "redis-preflight failed waiting for redis."
exit 1
fi
sleep 1
done
redis-cli -h redis FLUSHALL
echo "Flushed redis cache on startup."
storybook:
profiles:
- docs
build:
context: .
dockerfile: ./apps/storybook/Dockerfile
target: storybook-dev
ports:
- "${DEV_PORT_PREFIX:-30}05:6006"
networks:
- bt
restart: always
volumes:
- ./packages/theme:/storybook/packages/theme
- ./apps/storybook:/storybook/apps/storybook
docs:
profiles:
- docs
build:
context: .
dockerfile: ./apps/docs/Dockerfile
target: docs-dev
ports:
- "${DEV_PORT_PREFIX:-30}03:3000"
networks:
- bt
restart: always
volumes:
- ./apps/docs:/apps/docs
# if using staff photos in dev, use --profile dev
minio:
image: 'minio/minio:latest'
profiles:
- dev
ports:
- "${DEV_PORT_PREFIX:-30}06:9000"
- "${DEV_PORT_PREFIX:-30}07:9090"
environment:
MINIO_ROOT_USER: 'root'
MINIO_ROOT_PASSWORD: 'password'
networks:
- bt
volumes:
- 'minio:/data/minio'
command: minio server /data/minio --console-address ":9090"
createbuckets:
image: minio/mc
profiles:
- dev
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://localhost:9000 root password;
/usr/bin/mc mb myminio/images;
/usr/bin/mc anonymous set public myminio/images;
exit 0;
"
volumes:
minio:
driver: local
mongodb-db:
driver: local
mongodb-configdb:
driver: local