-
-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
468 lines (439 loc) · 14.9 KB
/
docker-compose.yml
File metadata and controls
468 lines (439 loc) · 14.9 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# This docker compose file needs docker compose version 2.20.2 or higher.
# See https://docs.docker.com/compose/profiles/ for documentation on using profiles
# and / or setting COMPOSE_PROFILES in your environment.
# Do not set environment variables in this file. Most people will want to set them in a .env file
# Unless you are developing or modifying a production system you should not need to modify this file.
#
# Support for logging to fluentd is provided, but you will need to set up a fluentd server
# and set the FLUENTD_ADDRESS environment variable to point to it.
# Then you will need to update each of the services that you want to log to fluentd
# fluentd is a log collector so that we can aggregate logs from multiple hosts running the composed application.
# see: https://betterstack.com/community/guides/logging/fluentd-explained/ to get started
x-json-file-logging: &json-file-logging
driver: "json-file"
options:
max-size: "1024m"
max-file: "3"
x-fluent-logging: &fluent-logging
driver: "fluentd"
options:
fluentd-address: host.docker.internal:24224
tag: runestone
fluentd-async-connect: "true"
mode: "non-blocking"
max-buffer-size: "8m"
services:
redis:
image: redis:6-alpine
restart: always
# The db service provides an easy way for new developers to get up and running quickly.
# it could also be used for a production system for a single department. For production
# setting up a separate database server is recommended. Advanced developers probably
# want to run their own postgresql server and set the environment variables to point to it.
db:
profiles: [ "basic" ]
image: postgres:13
restart: always
environment:
# setting these will create a user with this password and a database with this name
# this is a feature of the postgres docker image
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-runestone}
POSTGRES_USER: ${POSTGRES_USER:-runestone}
POSTGRES_DB: ${POSTGRES_DBNAME:-runestone_dev}
# use a non-standard port to avoid conflicts with other postgres instances on the host
ports:
- 2345:5432
# pgbouncer is for production only, when in a load balancer configuration.
# This will effectively limit the total number of connections to the database
# for the composed application to 30. If you need more than that you will need
# to set the PGBOUNCER_DEFAULT_POOL_SIZE environment variable to a larger number.
pgbouncer:
profiles: [ "production" ]
image: bitnamilegacy/pgbouncer:1.24.1-debian-12-r10
restart: always
ports:
- 6432:6432
extra_hosts:
- host.docker.internal:host-gateway
environment:
- POSTGRESQL_HOST=${POSTGRESQL_HOST}
- POSTGRESQL_DATABASE=${POSTGRESQL_DATABASE}
- PGBOUNCER_DATABASE=${POSTGRESQL_DATABASE}
- POSTGRESQL_USERNAME=${POSTGRESQL_USERNAME}
- POSTGRESQL_PASSWORD=${POSTGRESQL_PASSWORD}
- PGBOUNCER_AUTH_TYPE=trust #md5 or scram-sha-256
- PGBOUNCER_DEFAULT_POOL_SIZE=25
- PGBOUNCER_POOL_MODE=transaction
- PGBOUNCER_MAX_PREPARED_STATEMENTS=100
- PGBOUNCER_MAX_CLIENT_CONN=250
- PGBOUNCER_STATS_USERS=runestone
- PGBOUNCER_SERVER_FAST_CLOSE=0 # this is the default value but broke in a recent update
depends_on:
db:
condition: service_started
required: false
jobe:
build:
context: ./projects/jobe
image: ghcr.io/runestoneinteractive/rs-jobe
restart: always
book:
build:
context: ./projects/book_server
image: ghcr.io/runestoneinteractive/rs-book
hostname: book_${HOSTNAME:-dev}
extra_hosts:
- host.docker.internal:host-gateway
ports:
- 8111:8111
command: uvicorn rsptx.book_server_api.main:app --host 0.0.0.0 --port 8111
#command: tail -f /var/log/lastlog
restart: always
logging:
<<: *json-file-logging
options:
tag: runestone.book
# Additional logging options can be added here if needed
volumes:
- ${BOOK_PATH}:/usr/books
environment:
- BOOK_PATH=/usr/books
- SERVER_CONFIG=${SERVER_CONFIG}
- RUNESTONE_HOST=${RUNESTONE_HOST}
- RUNESTONE_PATH=/usr/src/app
- REDIS_URI=redis://${REDIS_HOST}:6379/0
# Note: host.docker.internal refers back to the host so we can just use a local instance
# of postgresql
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- DOCKER_COMPOSE=1
- JWT_SECRET=${JWT_SECRET}
- FERNET_SECRET=${FERNET_SECRET}
- UVICORN_WORKERS=${UVICORN_WORKERS:-2}
- UVICORN_USER=www-data
- UVICORN_GROUP=www-data
- UVICORN_MAX_REQUESTS=5000
- UVICORN_MAX_REQUESTS_JITTER=30
- UVICORN_TIMEOUT=60
- LOGIN_URL="/runestone/default/user"
- WORKER_NAME=${HOSTNAME}
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
- SPACES_KEY=${SPACES_KEY}
- SPACES_SECRET=${SPACES_SECRET}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- LTI1P3_PUBLIC_KEY=${LTI1P3_PUBLIC_KEY}
- LTI1P3_PRIVATE_KEY=${LTI1P3_PRIVATE_KEY}
depends_on:
redis:
condition: service_started
required: true
jobe:
condition: service_started
required: true
pgbouncer:
condition: service_started
required: false
db:
condition: service_started
required: false
runestone:
build:
context: ./projects/w2p_login_assign_grade
image: ghcr.io/runestoneinteractive/rs-runestone
hostname: runestone_${HOSTNAME:-dev}
extra_hosts:
- host.docker.internal:host-gateway
ports:
- 8112:8112
#command: gunicorn --bind 0.0.0.0:8112 rsptx.web2py_server.wsgihandler:application
# see projects/w2p_login_assign_grade/entrypoint.sh and the Dockerfile
restart: always
logging:
<<: *json-file-logging
options:
tag: runestone.runestone
volumes:
- ${BOOK_PATH}:/usr/books
environment:
- BOOK_PATH=/usr/books
- SERVER_CONFIG=${SERVER_CONFIG}
- WEB2PY_CONFIG=${SERVER_CONFIG}
- RUNESTONE_HOST=${RUNESTONE_HOST}
- RUNESTONE_PATH=/usr/src/app
- REDIS_URI=redis://${REDIS_HOST}:6379/0
# Note: host.docker.internal refers back to the host so we can just use a local instance
# of postgresql
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}?ssl=disable
- DBURL=${DC_DBURL:-$DBURL}?ssl=disable
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
- JWT_SECRET=${JWT_SECRET}
- FERNET_SECRET=${FERNET_SECRET}
- WEB2PY_PRIVATE_KEY=${WEB2PY_PRIVATE_KEY}
- ACADEMY_MODE=True
- USE_MASTER_AUTHOR=${USE_MASTER_AUTHOR:-False}
- EMAIL_SENDER=${EMAIL_SENDER}
- EMAIL_SERVER=${EMAIL_SERVER}
- EMAIL_LOGIN=${EMAIL_LOGIN}
- SPACES_KEY=${SPACES_KEY}
- SPACES_SECRET=${SPACES_SECRET}
- GUNICORN_CMD_ARGS=${GUNICORN_CMD_ARGS}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
- LTI1P3_PUBLIC_KEY=${LTI1P3_PUBLIC_KEY}
- LTI1P3_PRIVATE_KEY=${LTI1P3_PRIVATE_KEY}
- SERVER_PROTOCOL=${SERVER_PROTOCOL:-http://}
- ALLOW_INSECURE_LOGIN=${ALLOW_INSECURE_LOGIN:-True}
depends_on:
redis:
condition: service_started
required: true
jobe:
condition: service_started
required: true
pgbouncer:
condition: service_started
required: false
db:
condition: service_started
required: false
assignment:
build:
context: ./projects/assignment_server
image: ghcr.io/runestoneinteractive/rs-assignment
hostname: assignment_${HOSTNAME:-dev}
extra_hosts:
- host.docker.internal:host-gateway
ports:
- 8113:8113
command: uvicorn rsptx.assignment_server_api.core:app --host 0.0.0.0 --port 8113
#command: tail -f /var/log/lastlog
restart: always
logging:
<<: *json-file-logging
options:
tag: runestone.assignment
volumes:
- ${BOOK_PATH}:/usr/books
environment:
- BOOK_PATH=/usr/books
- SERVER_CONFIG=${SERVER_CONFIG}
- RUNESTONE_PATH=/usr/src/app
- REDIS_URI=redis://${REDIS_HOST}:6379/0
# Note: host.docker.internal refers back to the host so we can just use a local instance
# of postgresql
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- DOCKER_COMPOSE=1
- JWT_SECRET=${JWT_SECRET}
- FERNET_SECRET=${FERNET_SECRET}
- UVICORN_WORKERS=3
- UVICORN_USER=www-data
- UVICORN_GROUP=www-data
- UVICORN_MAX_REQUESTS=5000
- UVICORN_MAX_REQUESTS_JITTER=30
- UVICORN_TIMEOUT=60
- LOG_LEVEL=${LOG_LEVEL:-INFO}
depends_on:
redis:
condition: service_started
required: true
jobe:
condition: service_started
required: true
pgbouncer:
condition: service_started
required: false
db:
condition: service_started
required: false
nginx:
# Note we use context: ./ here so that the Dockerfile can copy from the components folder
build:
context: ./
dockerfile: projects/nginx/Dockerfile
image: ghcr.io/runestoneinteractive/rs-nginx
extra_hosts:
- host.docker.internal:host-gateway
restart: always
logging:
<<: *json-file-logging
options:
tag: runestone.nginx
ports:
# ports are specified host:container
- 80:80
#- 443:443
volumes:
- ${BOOK_PATH}:/usr/books
depends_on:
runestone:
condition: service_started
required: true
book:
condition: service_started
required: true
assignment:
condition: service_started
required: true
admin:
condition: service_started
required: false
author:
condition: service_started
required: false
# this second nginx is designed to sit in front of python servers running on a host machine for a more convineient dev environment
# it exposes the Runestone application on port 8080
nginx_dstart_dev:
profiles: [ "dev" ]
# Note we use context: ./ here so that the Dockerfile can copy from the components folder
build:
context: ./
dockerfile: projects/nginx_dstart_dev/Dockerfile
#image: registry.digitalocean.com/runestone-registry/rs-nginx
image: ghcr.io/runestoneinteractive/rs-nginx-dstart-dev
restart: always
ports:
# ports are specified host:container
- 8080:80
#- 443:443
volumes:
- ${BOOK_PATH}:/usr/books
- ./components/rsptx/templates/staticAssets:/usr/share/nginx/html/staticAssets
# create an image/container to run rsmanage inside the composed services
# docker compose run rsmanage rsmanage --help
rsmanage:
build:
context: ./projects/rsmanage
image: ghcr.io/runestoneinteractive/rs-rsmanage
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- ${BOOK_PATH}:/usr/books
environment:
- BOOK_PATH=/usr/books
- SERVER_CONFIG=${SERVER_CONFIG}
- RUNESTONE_HOST=${RUNESTONE_HOST}
- RUNESTONE_PATH=/usr/src/app
- REDIS_URI=redis://${REDIS_HOST}:6379/0
- DC_DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DC_DBURL=${DC_DBURL:-$DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- DOCKER_COMPOSE=1
- LOG_LEVEL=${LOG_LEVEL:-WARN}
- FERNET_SECRET=${FERNET_SECRET}
- JWT_SECRET=${JWT_SECRET}
- WEB2PY_PRIVATE_KEY=${WEB2PY_PRIVATE_KEY}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-runestone}
author:
profiles: [ "author" ]
build:
context: ./projects/author_server
#image: registry.digitalocean.com/runestone-registry/rs-author
image: ghcr.io/runestoneinteractive/rs-author
hostname: author_${HOSTNAME:-dev}
extra_hosts:
- host.docker.internal:host-gateway
ports:
- 8114:8114
logging:
<<: *json-file-logging
options:
tag: runestone.author
command: uvicorn rsptx.author_server_api.main:app --host 0.0.0.0 --port 8114
volumes:
- ${BOOK_PATH}:/books
- $HOME/downloads:/usr/src/app/downloads
environment:
- SERVER_CONFIG=${SERVER_CONFIG}
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- RUNESTONE_PATH=/usr/src/app
- JWT_SECRET=${JWT_SECRET}
depends_on:
redis:
condition: service_started
required: true
db:
condition: service_started
required: false
worker:
profiles: [ "author" ]
build:
context: ./projects/author_server
#image: registry.digitalocean.com/runestone-registry/rs-worker
image: ghcr.io/runestoneinteractive/rs-worker
hostname: worker_${HOSTNAME:-dev}
extra_hosts:
- host.docker.internal:host-gateway
logging:
<<: *json-file-logging
options:
tag: runestone.worker
command: celery -A rsptx.author_server_api.worker.celery worker
volumes:
- ${BOOK_PATH}:/books
- ${SSH_AUTH_SOCK:-/tmp}:/ssh-agent # forward host ssh agent
- $HOME/downloads:/usr/src/app/downloads
environment:
- SERVER_CONFIG=${SERVER_CONFIG}
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- RUNESTONE_PATH=/usr/src/app
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- WEB2PY_CONFIG=${SERVER_CONFIG}
- JWT_SECRET=${JWT_SECRET}
- SSH_AUTH_SOCK=/ssh-agent
- NUM_SERVERS=${NUM_SERVERS:-1}
- BOOK_PATH=/books
depends_on:
author:
condition: service_started
required: true
redis:
condition: service_started
required: true
db:
condition: service_started
required: false
admin:
build:
context: ./projects/admin_server
dockerfile: Dockerfile
image: ghcr.io/runestoneinteractive/rs-admin
extra_hosts:
- host.docker.internal:host-gateway
container_name: admin
restart: always
logging:
<<: *json-file-logging
options:
tag: runestone.admin
ports:
- "8115:8115"
volumes:
- ${BOOK_PATH}:/usr/books
environment:
- BOOK_PATH=/usr/books
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
- SERVER_CONFIG=${SERVER_CONFIG}
- RUNESTONE_PATH=/usr/src/app
- RUNESTONE_HOST=${RUNESTONE_HOST}
- JWT_SECRET=${JWT_SECRET}
# - DEV_DBURL postgresql://runestone:runestone@host.docker.internal/runestone_dev
- REDIS_URI=redis://${REDIS_HOST}:6379/0
# Note: host.docker.internal refers back to the host so we can just use a local instance
# of postgresql
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- DOCKER_COMPOSE=1
- LTI1P3_PUBLIC_KEY=${LTI1P3_PUBLIC_KEY}
- LTI1P3_PRIVATE_KEY=${LTI1P3_PRIVATE_KEY}
- FORWARDED_ALLOW_IPS=*
depends_on:
redis:
condition: service_started
required: true