-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
docker-compose.yml
378 lines (357 loc) · 11.8 KB
/
docker-compose.yml
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
# 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.
#
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: bitnami/pgbouncer:latest
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:
driver: "json-file"
options:
max-size: "1024m"
max-file: "3"
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}
- 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}
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:
driver: "json-file"
options:
max-size: "1024m"
max-file: "3"
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}
- DBURL=${DC_DBURL:-$DBURL}
- LOAD_BALANCER_HOST=${LOAD_BALANCER_HOST}
- JWT_SECRET=${JWT_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}
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:
driver: "json-file"
options:
max-size: "1024m"
max-file: "3"
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}
- 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
restart: always
logging:
driver: "json-file"
options:
max-size: "1024m"
max-file: "3"
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
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
- DEV_DBURL=${DC_DEV_DBURL:-$DEV_DBURL}
- DBURL=${DC_DBURL:-$DBURL}
- DOCKER_COMPOSE=1
- LOG_LEVEL=${LOG_LEVEL:-WARN}
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
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}
- 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
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