forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.production.yml
317 lines (301 loc) · 9.18 KB
/
docker-compose.production.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
##
## Production server config (wip)
## You probably want to run:
## export COMPOSE_FILE="docker-compose.yml:docker-compose.production.yml"
## docker-compose up -d
##
version: "3.8"
services:
web:
profiles: ["ol-web1", "ol-web2"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- GUNICORN_OPTS= --workers 50 --timeout 300 --max-requests 500
- OL_CONFIG=/olsystem/etc/openlibrary.yml
- BEFORE_START=pip install -e /booklending_utils
volumes:
- ../booklending_utils:/booklending_utils
- ../olsystem:/olsystem
- ../olsystem/etc/ia.ini:/home/openlibrary/.config/ia.ini
solr:
profiles: ["ol-solr0"]
environment:
# More memory for production
- SOLR_JAVA_MEM=-Xms10g -Xmx10g
restart: unless-stopped
solr_haproxy:
profiles: ["ol-solr0"]
image: haproxy:2.3.5
restart: unless-stopped
networks:
- webnet
volumes:
- ./conf/solr/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- 8984:8984
logging:
options:
max-size: "512m"
max-file: "4"
solr_restarter:
profiles: ["ol-solr0"]
build: scripts/solr_restarter
restart: unless-stopped
environment:
- TEST_URL=http://openlibrary.org/search.json?q=hello&mode=everything&limit=0
- CONTAINER_NAMES=openlibrary_solr_1 openlibrary_solr_haproxy_1
# XXX this service doesn't have internet access at the moment
#- SEND_SLACK_MESSAGE=true
env_file:
- ../olsystem/etc/solr_restarter.env
volumes:
# Forward the docker socket, since this needs to be able to
# run docker commands
- "/var/run/docker.sock:/var/run/docker.sock"
logging:
options:
max-size: "512m"
max-file: "4"
covers:
profiles: ["ol-covers0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- GUNICORN_OPTS= --workers 30 --max-requests 500
- COVERSTORE_CONFIG=/olsystem/etc/coverstore.yml
volumes:
- ../olsystem:/olsystem
- /1:/1
deploy:
replicas: 2
covers_nginx:
profiles: ["ol-covers0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
user: root
command: docker/ol-nginx-start.sh
environment:
- CRONTAB_FILES=/etc/cron.d/archive-webserver-logs
restart: unless-stopped
depends_on:
- covers
volumes:
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/covers_nginx.conf:/etc/nginx/sites-enabled/covers_nginx.conf:ro
# Needed for HTTPS, since this is a public server
- ./docker/public_nginx.conf:/etc/nginx/sites-available/public_nginx.conf:ro
# Needs access to openlibrary for static files
- ../olsystem:/olsystem
- /1/var/lib/openlibrary/sitemaps/sitemaps:/sitemaps
# web log rotation
- ../olsystem/etc/logrotate.d/nginx:/etc/logrotate.d/nginx
# Persist the nginx logs
- /1/var/log/nginx:/var/log/nginx
# Archive nginx logs regularly
- ../olsystem/etc/cron.d/archive-webserver-logs:/etc/cron.d/archive-webserver-logs
- archive-webserver-logs-data:/archive-webserver-logs-data
ports:
- 80:80
- 443:443
networks:
- webnet
logging:
options:
max-size: "512m"
max-file: "4"
secrets:
# Needed by public_nginx.conf
- ssl_certificate
- ssl_certificate_key
memcached:
profiles: ["ol-covers0"]
cron-jobs:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
hostname: "$HOSTNAME"
user: root
command: docker/ol-cron-start.sh
restart: unless-stopped
volumes:
- ../olsystem/etc/cron.d/openlibrary.ol_home0:/etc/cron.d/openlibrary.ol_home0:ro
- ../olsystem:/olsystem
- /1/var/tmp:/1/var/tmp
networks:
- webnet
- dbnet
secrets:
- ia_db_pw_file
infobase:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- INFOBASE_OPTS= fastcgi
- INFOBASE_CONFIG=/olsystem/etc/infobase.yml
volumes:
- ../olsystem:/olsystem
- infobase-writelog:/1/var/lib/openlibrary/infobase/log
- infobase-errorlog:/1/var/log/openlibrary/infobase-errors
web_haproxy:
profiles: ["ol-www0"]
image: haproxy:2.3.5
restart: unless-stopped
hostname: "$HOSTNAME"
networks:
- webnet
volumes:
- ../olsystem/etc/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- 7072:7072
logging:
options:
max-size: "512m"
max-file: "4"
web_nginx:
profiles: ["ol-www0"]
restart: unless-stopped
hostname: "ol-www0" # always want this hostname (or nginx backups will be misnamed)
image: "${OLIMAGE:-openlibrary/olbase:latest}"
user: root
command: docker/ol-nginx-start.sh
environment:
- CRONTAB_FILES=/etc/cron.d/archive-webserver-logs
volumes:
# nginx configurations
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/web_nginx.conf:/etc/nginx/sites-enabled/openlibrary.conf:ro
# Needed for HTTPS, since this is a public server
- ./docker/public_nginx.conf:/etc/nginx/sites-available/public_nginx.conf:ro
# archive web log uploads
- ../olsystem:/olsystem
# web log rotation
- ../olsystem/etc/logrotate.d/nginx:/etc/logrotate.d/nginx
# Persist the nginx logs
- /1/var/log/nginx:/var/log/nginx
# sitemap generation (we also need olsystem/etc/cron.d + openlibrary/scripts)
- /1/var/lib/openlibrary/sitemaps/sitemaps:/sitemaps
# Archive nginx logs regularly
- ../olsystem/etc/cron.d/archive-webserver-logs:/etc/cron.d/archive-webserver-logs
- archive-webserver-logs-data:/archive-webserver-logs-data
ports:
- 80:80
- 443:443
networks:
- webnet
logging:
options:
max-size: "512m"
max-file: "4"
secrets:
- ssl_certificate
- ssl_certificate_key
infobase_nginx:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
user: root
command: docker/ol-nginx-start.sh
restart: unless-stopped
depends_on:
- infobase
volumes:
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/infobase_nginx.conf:/etc/nginx/sites-enabled/infobase_nginx.conf:ro
# Needs olsystem for black-listed IPs
- ../olsystem:/olsystem
# Log rotation
- ../olsystem/etc/logrotate.d/nginx:/etc/logrotate.d/nginx
ports:
- 7000:7000
networks:
- webnet
affiliate-server:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- AFFILIATE_CONFIG=/openlibrary.yml
command: docker/ol-affiliate-server-start.sh
ports:
- 31337:31337
volumes:
- /opt/olsystem/etc/openlibrary.yml:/openlibrary.yml
networks:
- webnet
logging:
options:
max-size: "512m"
max-file: "4"
solr-updater:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- OL_CONFIG=/olsystem/etc/openlibrary.yml
- OL_URL=https://openlibrary.org/
- EXTRA_OPTS=--solr-url http://ol-solr0:8984/solr/openlibrary
--no-solr-next
volumes:
- ../olsystem:/olsystem
logging:
options:
max-size: "512m"
max-file: "4"
secrets:
- ia_db_pw_file
# solr-updater running for the "next" version of solr we will deploy
solr-next-updater:
# Set it to something so that it never starts by default ; we have to
# explicitly start it (usually only when a solr reindex project is in progress)
profiles: ["ol-never"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- PYENV_VERSION=${PYENV_VERSION:-}
- OL_CONFIG=/olsystem/etc/openlibrary.yml
- OL_URL=https://openlibrary.org/
- STATE_FILE=solr-next-update.offset
- EXTRA_OPTS=--solr-url http://ol-solr1:8984/solr/openlibrary --solr-next
volumes:
- solr-updater-data:/solr-updater-data
- ../olsystem:/olsystem
secrets:
- ia_db_pw_file
command: docker/ol-solr-updater-start.sh
networks:
- webnet
- dbnet
importbot:
profiles: ["ol-home0"]
image: "${OLIMAGE:-openlibrary/olbase:latest}"
command: docker/ol-importbot-start.sh
restart: unless-stopped
hostname: "$HOSTNAME"
environment:
- OL_CONFIG=/olsystem/etc/openlibrary.yml
- OPENLIBRARY_RCFILE=/olsystem/etc/olrc-importbot
- PYENV_VERSION=${PYENV_VERSION:-}
volumes:
- ../olsystem:/olsystem
networks:
- webnet
- dbnet
# secrets mounted to /run/secrets/
# e.g. /run/secrets/ia_db_pw_file
secrets:
ia_db_pw_file:
file: /opt/.petabox/dbserver
# SSL-related secrets
ssl_certificate:
file: /opt/.petabox/openlibrary.org.combined.crt
ssl_certificate_key:
file: /opt/.petabox/openlibrary.org.nopassword.key
volumes:
infobase-writelog:
infobase-errorlog:
archive-webserver-logs-data: