@@ -205,3 +205,51 @@ healthcheck:
205
205
timeout: 10s
206
206
retries: 3
207
207
```
208
+
209
+ ### Running all worker processes in a single container
210
+
211
+ Anyone looking to run Synapse workers with docker in production should use one container
212
+ per Synapse process, specifying a different worker config per container.
213
+ However, if for some reason you want to run all Synapse processes in the same
214
+ container, [ Dockerfile-workers] ( Dockerfile-workers ) will provide that functionality (the
215
+ team currently use this image for
216
+ [ Complement testing] ( https://github.com/matrix-org/complement ) , which requires a complete
217
+ homeserver bundled in a single docker image).
218
+
219
+ The Dockerfile will create a container with any desired Synapse worker processes, as well as
220
+ a nginx to route traffic accordingly, a redis for worker communication and a supervisord
221
+ instance to start up and monitor all processes. You will need to provide your own postgres
222
+ container to connect to. TLS is not handled by the container. A reverse proxy should be
223
+ placed in front the exposed HTTP port for the purposes of TLS termination.
224
+
225
+ Note that the worker Dockerfile is based off the main ` [Dockerfile](Dockerfile) ` . If you
226
+ would like to build from the current checkout, first build the main Synapse docker image
227
+ using the instructions in [ Building the image] ( #building-the-image ) , then afterwards build the
228
+ worker image:
229
+
230
+ ```
231
+ docker build -t matrixdotorg/synapse:workers -f docker/Dockerfile-workers .
232
+ ```
233
+
234
+ To start a container, use the following:
235
+
236
+ ```
237
+ docker run -d --name synapse \
238
+ --mount type=volume,src=synapse-data,dst=/data \
239
+ -p 8008:8080 \
240
+ -e SYNASPE_SERVER_NAME=my.matrix.host \
241
+ -e SYNAPSE_REPORT_STATS=yes \
242
+ -e SYNAPSE_WORKERS=synchrotron,media_repository,user_dir \
243
+ matrixdotorg/synapse:workers
244
+ ```
245
+
246
+ The ` SYNAPSE_WORKERS ` environment variable is a comma-separated list of workers to use
247
+ when running the container. All possible worker names are defined by the keys of the
248
+ ` WORKERS_CONFIG ` variable in [ this script] ( configure_workers_and_start.py ) , which the
249
+ Dockerfile makes use of to generate appropriate worker, nginx and supervisord config files.
250
+
251
+ Otherwise, ` SYNAPSE_WORKERS ` can be set to ` * ` to use all possible workers, or either left
252
+ empty or unset to spawn no workers. The container is configured to use redis-based worker mode.
253
+
254
+ Note that currently only one instance of a worker can be spun up at once, but this may
255
+ improve in the future.
0 commit comments