2017-09-28 06:12:47 -04:00
# Synapse Docker
2018-02-04 09:27:32 -05:00
This Docker image will run Synapse as a single process. It does not provide any
database server or TURN server that you should run separately.
If you run a Postgres server, you should simply have it in the same Compose
project or set the proper environment variables and the image will automatically
use that server.
2017-09-28 06:12:47 -04:00
## Build
Build the docker image with the `docker build` command from the root of the synapse repository.
```
2017-09-29 05:40:15 -04:00
docker build -t matrixdotorg/synapse:v0.22.1 .
2017-09-28 06:12:47 -04:00
```
2017-09-29 05:40:15 -04:00
The `-t` option sets the image tag. Official images are tagged `matrixdotorg/synapse:<version>` where `<version>` is the same as the release tag in the synapse git repository.
2017-09-28 06:12:47 -04:00
2018-02-04 09:27:32 -05:00
You may have a local Python wheel cache available, in which case copy the relevant packages in the ``cache/`` directory at the root of the project.
2017-09-28 06:12:47 -04:00
2018-02-04 09:27:32 -05:00
## Run
2017-09-28 06:12:47 -04:00
2018-02-04 09:27:32 -05:00
It is recommended that you use Docker Compose to run your containers, including
this image and a Postgres server. A sample ``docker-compose.yml`` is provided,
2018-02-04 10:18:40 -05:00
including example labels for reverse proxying and other artifacts.
2017-09-28 06:12:47 -04:00
2018-02-04 09:27:32 -05:00
Then, to run the server:
2017-09-28 06:12:47 -04:00
```
2018-02-04 09:27:32 -05:00
docker-compose up -d
2017-09-28 06:12:47 -04:00
```
2018-02-04 09:27:32 -05:00
In the case you specified a custom path for you configuration file and wish to
generate a fresh ``homeserver.yaml``, simply run:
2017-09-28 06:12:47 -04:00
```
2018-02-04 10:18:40 -05:00
docker-compose run --rm synapse generate
2017-09-28 06:12:47 -04:00
```
2018-02-04 09:27:32 -05:00
If you do not wish to use Compose, you may still run this image using plain
2018-02-04 10:18:40 -05:00
Docker commands. Note that the following is just a guideline and you may need
to add parameters to the docker run command to account for the network situation
with your postgres database.
2017-09-28 06:12:47 -04:00
```
docker run \
-d \
--name synapse \
2018-02-04 09:27:32 -05:00
-v ${DATA_PATH}:/data \
-e SYNAPSE_SERVER_NAME=my.matrix.host \
2017-09-29 05:40:15 -04:00
matrixdotorg/synapse:v0.22.1
2017-09-28 06:12:47 -04:00
```
2018-02-04 09:27:32 -05:00
## Volumes
2018-02-04 10:18:40 -05:00
The image expects a single volume, located at ``/data``, that will hold:
2018-02-04 09:27:32 -05:00
* temporary files during uploads;
* uploaded media and thumbnais;
* the SQLite database if you do not configure postgres.
## Environment
2018-02-04 10:18:40 -05:00
Unless you specify a custom path for the configuration file, a very generic
2018-02-04 09:27:32 -05:00
file will be generated, based on the following environment settings.
These are a good starting point for setting up your own deployment.
2018-02-04 10:18:40 -05:00
Global settings:
* ``UID``, the user id Synapse will run as [default 991]
* ``GID``, the group id Synapse will run as [default 991]
2018-02-04 09:27:32 -05:00
Synapse specific settings:
* ``SYNAPSE_SERVER_NAME`` (mandatory), the current server public hostname.
* ``SYNAPSE_CONFIG_PATH``, path to a custom config file (will ignore all
other options then).
* ``SYNAPSE_NO_TLS``, set this variable to disable TLS in Synapse (use this if
you run your own TLS-capable reverse proxy).
* ``SYNAPSE_WEB_CLIENT``, set this variable to enable the embedded Web client.
* ``SYNAPSE_ENABLE_REGISTRATION``, set this variable to enable registration on
the Synapse instance.
* ``SYNAPSE_ALLOW_GUEST``, set this variable to allow guest joining this server.
* ``SYNAPSE_EVENT_CACHE_SIZE``, the event cache size [default `10K` ].
* ``SYNAPSE_REPORT_STATS``, set this variable to `yes` to enable anonymous
statistics reporting back to the Matrix project which helps us to get funding.
2018-02-05 15:28:15 -05:00
* ``SYNAPSE_RECAPTCHA_PUBLIC_KEY``, set this variable to the recaptcha public
key in order to enable recaptcha upon registration
* ``SYNAPSE_RECAPTCHA_PRIVATE_KEY``, set this variable to the recaptcha private
key in order to enable recaptcha upon registration
2018-02-04 09:27:32 -05:00
Shared secrets, these will be initialized to random values if not set:
* ``SYNAPSE_REGISTRATION_SHARED_SECRET``, secret for registrering users if
registration is disable.
* ``SYNAPSE_MACAROON_SECRET_KEY``, secret for Macaroon.
Database specific values (will use SQLite if not set):
* `POSTGRES_DATABASE` - The database name for the synapse postgres database. [default: `matrix` ]
* `POSTGRES_HOST` - The host of the postgres database if you wish to use postgresql instead of sqlite3. [default: `db` which is useful when using a container on the same docker network in a compose file where the postgres service is called `db` ]
* `POSTGRES_PASSWORD` - The password for the synapse postgres database. **If this is set then postgres will be used instead of sqlite3.** [default: none] **NOTE** : You are highly encouraged to use postgresql! Please use the compose file to make it easier to deploy.
* `POSTGRES_USER` - The user for the synapse postgres database. [default: `matrix` ]