Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

Add a dockerfile for running a set of Synapse worker processes (#9162) This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).
3 anni fa
Add a dockerfile for running a set of Synapse worker processes (#9162) This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).
3 anni fa
Add a dockerfile for running a set of Synapse worker processes (#9162) This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).
3 anni fa
Add a dockerfile for running a set of Synapse worker processes (#9162) This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).
3 anni fa
Add a dockerfile for running a set of Synapse worker processes (#9162) This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).
3 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # Synapse Docker
  2. This Docker image will run Synapse as a single process. By default it uses a
  3. sqlite database; for production use you should connect it to a separate
  4. postgres database. The image also does *not* provide a TURN server.
  5. This image should work on all platforms that are supported by Docker upstream.
  6. Note that Docker's WS1-backend Linux Containers on Windows
  7. platform is [experimental](https://github.com/docker/for-win/issues/6470) and
  8. is not supported by this image.
  9. ## Volumes
  10. By default, the image expects a single volume, located at `/data`, that will hold:
  11. * configuration files;
  12. * uploaded media and thumbnails;
  13. * the SQLite database if you do not configure postgres;
  14. * the appservices configuration.
  15. You are free to use separate volumes depending on storage endpoints at your
  16. disposal. For instance, `/data/media` could be stored on a large but low
  17. performance hdd storage while other files could be stored on high performance
  18. endpoints.
  19. In order to setup an application service, simply create an `appservices`
  20. directory in the data volume and write the application service Yaml
  21. configuration file there. Multiple application services are supported.
  22. ## Generating a configuration file
  23. The first step is to generate a valid config file. To do this, you can run the
  24. image with the `generate` command line option.
  25. You will need to specify values for the `SYNAPSE_SERVER_NAME` and
  26. `SYNAPSE_REPORT_STATS` environment variable, and mount a docker volume to store
  27. the configuration on. For example:
  28. ```
  29. docker run -it --rm \
  30. --mount type=volume,src=synapse-data,dst=/data \
  31. -e SYNAPSE_SERVER_NAME=my.matrix.host \
  32. -e SYNAPSE_REPORT_STATS=yes \
  33. matrixdotorg/synapse:latest generate
  34. ```
  35. For information on picking a suitable server name, see
  36. https://matrix-org.github.io/synapse/latest/setup/installation.html.
  37. The above command will generate a `homeserver.yaml` in (typically)
  38. `/var/lib/docker/volumes/synapse-data/_data`. You should check this file, and
  39. customise it to your needs.
  40. The following environment variables are supported in `generate` mode:
  41. * `SYNAPSE_SERVER_NAME` (mandatory): the server public hostname.
  42. * `SYNAPSE_REPORT_STATS` (mandatory, `yes` or `no`): whether to enable
  43. anonymous statistics reporting.
  44. * `SYNAPSE_HTTP_PORT`: the port Synapse should listen on for http traffic.
  45. Defaults to `8008`.
  46. * `SYNAPSE_CONFIG_DIR`: where additional config files (such as the log config
  47. and event signing key) will be stored. Defaults to `/data`.
  48. * `SYNAPSE_CONFIG_PATH`: path to the file to be generated. Defaults to
  49. `<SYNAPSE_CONFIG_DIR>/homeserver.yaml`.
  50. * `SYNAPSE_DATA_DIR`: where the generated config will put persistent data
  51. such as the database and media store. Defaults to `/data`.
  52. * `UID`, `GID`: the user id and group id to use for creating the data
  53. directories. If unset, and no user is set via `docker run --user`, defaults
  54. to `991`, `991`.
  55. * `SYNAPSE_LOG_LEVEL`: the log level to use (one of `DEBUG`, `INFO`, `WARNING` or `ERROR`).
  56. Defaults to `INFO`.
  57. * `SYNAPSE_LOG_SENSITIVE`: if set and the log level is set to `DEBUG`, Synapse
  58. will log sensitive information such as access tokens.
  59. This should not be needed unless you are a developer attempting to debug something
  60. particularly tricky.
  61. * `SYNAPSE_LOG_TESTING`: if set, Synapse will log additional information useful
  62. for testing.
  63. ## Postgres
  64. By default the config will use SQLite. See the [docs on using Postgres](https://github.com/matrix-org/synapse/blob/develop/docs/postgres.md) for more info on how to use Postgres. Until this section is improved [this issue](https://github.com/matrix-org/synapse/issues/8304) may provide useful information.
  65. ## Running synapse
  66. Once you have a valid configuration file, you can start synapse as follows:
  67. ```
  68. docker run -d --name synapse \
  69. --mount type=volume,src=synapse-data,dst=/data \
  70. -p 8008:8008 \
  71. matrixdotorg/synapse:latest
  72. ```
  73. (assuming 8008 is the port Synapse is configured to listen on for http traffic.)
  74. You can then check that it has started correctly with:
  75. ```
  76. docker logs synapse
  77. ```
  78. If all is well, you should now be able to connect to http://localhost:8008 and
  79. see a confirmation message.
  80. The following environment variables are supported in `run` mode:
  81. * `SYNAPSE_CONFIG_DIR`: where additional config files are stored. Defaults to
  82. `/data`.
  83. * `SYNAPSE_CONFIG_PATH`: path to the config file. Defaults to
  84. `<SYNAPSE_CONFIG_DIR>/homeserver.yaml`.
  85. * `SYNAPSE_WORKER`: module to execute, used when running synapse with workers.
  86. Defaults to `synapse.app.homeserver`, which is suitable for non-worker mode.
  87. * `UID`, `GID`: the user and group id to run Synapse as. If unset, and no user
  88. is set via `docker run --user`, defaults to `991`, `991`. Note that this user
  89. must have permission to read the config files, and write to the data directories.
  90. * `TZ`: the [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) the container will run with. Defaults to `UTC`.
  91. For more complex setups (e.g. for workers) you can also pass your args directly to synapse using `run` mode. For example like this:
  92. ```
  93. docker run -d --name synapse \
  94. --mount type=volume,src=synapse-data,dst=/data \
  95. -p 8008:8008 \
  96. matrixdotorg/synapse:latest run \
  97. -m synapse.app.generic_worker \
  98. --config-path=/data/homeserver.yaml \
  99. --config-path=/data/generic_worker.yaml
  100. ```
  101. If you do not provide `-m`, the value of the `SYNAPSE_WORKER` environment variable is used. If you do not provide at least one `--config-path` or `-c`, the value of the `SYNAPSE_CONFIG_PATH` environment variable is used instead.
  102. ## Generating an (admin) user
  103. After synapse is running, you may wish to create a user via `register_new_matrix_user`.
  104. This requires a `registration_shared_secret` to be set in your config file. Synapse
  105. must be restarted to pick up this change.
  106. You can then call the script:
  107. ```
  108. docker exec -it synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml --help
  109. ```
  110. Remember to remove the `registration_shared_secret` and restart if you no-longer need it.
  111. ## TLS support
  112. The default configuration exposes a single HTTP port: http://localhost:8008. It
  113. is suitable for local testing, but for any practical use, you will either need
  114. to use a reverse proxy, or configure Synapse to expose an HTTPS port.
  115. For documentation on using a reverse proxy, see
  116. https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md.
  117. For more information on enabling TLS support in synapse itself, see
  118. https://matrix-org.github.io/synapse/latest/setup/installation.html#tls-certificates. Of
  119. course, you will need to expose the TLS port from the container with a `-p`
  120. argument to `docker run`.
  121. ## Legacy dynamic configuration file support
  122. The docker image used to support creating a dynamic configuration file based
  123. on environment variables. This is no longer supported, and an error will be
  124. raised if you try to run synapse without a config file.
  125. It is, however, possible to generate a static configuration file based on
  126. the environment variables that were previously used. To do this, run the docker
  127. container once with the environment variables set, and `migrate_config`
  128. command line option. For example:
  129. ```
  130. docker run -it --rm \
  131. --mount type=volume,src=synapse-data,dst=/data \
  132. -e SYNAPSE_SERVER_NAME=my.matrix.host \
  133. -e SYNAPSE_REPORT_STATS=yes \
  134. matrixdotorg/synapse:latest migrate_config
  135. ```
  136. This will generate the same configuration file as the legacy mode used, and
  137. will store it in `/data/homeserver.yaml`. You can then use it as shown above at
  138. [Running synapse](#running-synapse).
  139. Note that the defaults used in this configuration file may be different to
  140. those when generating a new config file with `generate`: for example, TLS is
  141. enabled by default in this mode. You are encouraged to inspect the generated
  142. configuration file and edit it to ensure it meets your needs.
  143. ## Building the image
  144. If you need to build the image from a Synapse checkout, use the following `docker
  145. build` command from the repo's root:
  146. ```
  147. DOCKER_BUILDKIT=1 docker build -t matrixdotorg/synapse -f docker/Dockerfile .
  148. ```
  149. You can choose to build a different docker image by changing the value of the `-f` flag to
  150. point to another Dockerfile.
  151. ## Disabling the healthcheck
  152. If you are using a non-standard port or tls inside docker you can disable the healthcheck
  153. whilst running the above `docker run` commands.
  154. ```
  155. --no-healthcheck
  156. ```
  157. ## Disabling the healthcheck in docker-compose file
  158. If you wish to disable the healthcheck via docker-compose, append the following to your service configuration.
  159. ```
  160. healthcheck:
  161. disable: true
  162. ```
  163. ## Setting custom healthcheck on docker run
  164. If you wish to point the healthcheck at a different port with docker command, add the following
  165. ```
  166. --health-cmd 'curl -fSs http://localhost:1234/health'
  167. ```
  168. ## Setting the healthcheck in docker-compose file
  169. You can add the following to set a custom healthcheck in a docker compose file.
  170. You will need docker-compose version >2.1 for this to work.
  171. ```
  172. healthcheck:
  173. test: ["CMD", "curl", "-fSs", "http://localhost:8008/health"]
  174. interval: 15s
  175. timeout: 5s
  176. retries: 3
  177. start_period: 5s
  178. ```
  179. ## Using jemalloc
  180. Jemalloc is embedded in the image and will be used instead of the default allocator.
  181. You can read about jemalloc by reading the Synapse
  182. [Admin FAQ](https://matrix-org.github.io/synapse/latest/usage/administration/admin_faq.html#help-synapse-is-slow-and-eats-all-my-ramcpu).