Sign inSign up

realtyem/synapse

By realtyem

Updated about 6 hours ago

Synapse Docker image based on matrixdotorg's workers dockerfile. Built for use on Unraid.

Image
0

50K+

realtyem/synapse repository overview

BIG FAT WARNING BITS: You need to read up on what matrix is. Decisions made here can't be changed later. Once you begin to federate with other
homeservers(including the official "matrix.org" server, make sure you back up your keys(definitely) and database(definitely). If you rebuild your homeserver
and don't have the same keys, any other homeserver that's connected to your's will not be happy and may reject you.
Decide early what you want your server name to be. For instance, if you want to be reachable at '@someone:example.com' make sure your server name
is 'example.com' and not 'matrix.example.com'. More info from the manual here. Read up on delegation. I'll try and cover it somewhere later.

Two things make this container better than others I've seen.

  1. You can delete your homeserver.yaml(the main configuration file) and it will just remake it based on variables you declare. Keeps everything clean and up-to-date. Everything can be stored in the template for ease of use. If you use an existing homeserver.yaml, you will need to edit homeserver.yaml manually to use 8080 as the main listener port instead of the default 8008 because of the internal reverse proxy.
  2. Adding workers so that it can truly be multiprocess capable so as simple as adding the names to a variable and recreating(force updating) the image. All the details including reverse proxy and replication is handled for you. Add and remove workers as you want.

Main Configuration manual from Matrix.org:here.
Keep in mind some of this stuff won't apply. Like ridiculous amounts of reverse proxying.

Required Template bits:

  • SYNAPSE_SERVER_NAME: example.com or matrix.example.com or some such.
  • SYNAPSE_REPORT_STATS: yes or no, explicitly can't be true or false or 1 or 0.

These variables below can be set so that every time the image is updated/remade they will activate.

  • SYNAPSE_WORKER_TYPES= (any of those below, theoretical support for sharded event persistor. Can also just leave it blank(or empty) to run in monolith mode. For a good working set of most workers that definitely work correctly, just put "full" in here. If you change this value often, you may notice POSTGRES errors a lot related to database locking. If so, give it about ten seconds then restart the container. May have to do multiple times. They did not write Fair Queueing into the database access system.

All options of worker types:
account_data, event_persister, presence, receipts, to_device, typing
background_worker, event_creator, frontend_proxy, media_repository, pusher, synchrotron, user_dir,
client_reader, federation_sender, federation_inbound, federation_reader
"full" comprises:
account_data,background_worker,event_creator,event_persister,federation_inbound,federation_reader,federation_sender,frontend_proxy,media_repository,presence,pusher,receipts,to_device,typing,synchrotron,user_dir


Configuration generation bits:
Everything below can be added but isn't required to get everything up. Most just allow for easier regeneration of main configuration.

  • SYNAPSE_WORKERS_WRITE_LOGS_TO_DISK=1 or 0
  • SYNAPSE_LOG_LEVEL=ERROR, WARNING, INFO, DEBUG. INFO is default
  • SYNAPSE_METRICS: 'yes', '1', 'true', or 'on'. Anything else is a 'no'
  • POSTGRES_HOST=127.0.0.1 or whatever you use. Database is not builtin. Default is 'db'
  • POSTGRES_PORT=5432 which is the default.
  • POSTGRES_DB: synapse is the default
  • POSTGRES_USER=db_synapse_user Default is 'synapse'
  • POSTGRES_PASSWORD=db_synapse_password Not required to set as the defaults are good. Only accessed on first generate of main config, ignored otherwise.
  • SYNAPSE_CONFIG_DIR: /data is the default
  • SYNAPSE_DATA_DIR: /data is the default
  • SYNAPSE_CONFIG_PATH: SYNAPSE_CONFIG_DIR + /homeserver.yaml is the default.
  • SYNAPSE_NO_TLS: leave this alone, it gets overridden in the source because "unsupported in worker mode". You should be on Unraid, your reverse proxy handles this anyways.
  • SYNAPSE_EVENT_CACHE_SIZE: default is 10K, don't bother changing as there are better ways to increase caching if you have the RAM.
  • SYNAPSE_MAX_UPLOAD_SIZE: default is 50M. Recommend changing to 2048M to avoid uploading issues. Nginx will be the bottleneck.
  • SYNAPSE_TURN_URIS: list of URLs for turn servers, separate by a comma, no spaces
  • SYNAPSE_TURN_SECRET: super secret string for not having to use annoying passwords and stuff for turn. Look it up.
  • SYNAPSE_ENABLE_REGISTRATION: don't use this by default, huge security hole.
  • SYNAPSE_REGISTRATION_SHARED_SECRET: (this will be autogenerated for you)
  • SYNAPSE_MACAROON_SECRET_KEY: (this will be autogenerated for you, probably saved as a file.)
  • SYNAPSE_ALLOW_GUEST:
  • SYNAPSE_LOG_SENSITIVE: 1 or 0, default 0. This will input sensitive database bits into the logs. Won't need unless debugging.
  • SYNAPSE_AS_REGISTRATION_DIR: path to the yaml Application service files, if using.
  • SYNAPSE_APPSERVICES: same as above? Not sure.
  • SYNAPSE_LOG_CONFIG: path and file or default homeserver log.config template file. Default is /data/log.config
  • SYNAPSE_SERVE_SERVER_WELLKNOWN: True or False, default false. Change to true for federated mode plus delegation. Won't be used if behind reverse proxy.
  • SYNAPSE_PUBLIC_BASEURL: full "https://matrix.example.com" used for delegation. If you use 'example.com' as your server name, but reverse proxy
    to 'matrix.example.com', then put the 'matrix.example.com' here.
  • UID: defaults to 991
  • GID: defaults to 991. Isn't that the group ID for dnsmasq?

Paths to map to somewhere as volumes

  • /data (Required: where your configs live. Should be mapped to appdata/synapse.
  • /data/media_store (Recommended: thumbnails, other images, videos, other media lives here. Only map this if you want this not on your Unraid's appdata. Warning: can
    get quite large if active and federated.)
  • /var/lib/prometheus (Recommended: where the metrics database lives. SQLite. If not set it will be added to the container and stats will be lost each time the container is updated or rebuilt.)
  • /var/run/postgresql (Optional: where the postgres unix socket lives. Can't do the same to redis...yet)

Additions: anything in this section can be enabled by giving it a value of 'yes', 'y', '1', 'true', 't', or 'on'. Anything else is a 'no'

  • SYNAPSE_METRICS:
    This will enable the builtin prometheus service and add the necessary bits to Synapse to expose metrics.
  • SYNAPSE_ENABLE_REDIS_METRIC_EXPORT:
    Redis is built into the docker image. It will automatically be used whenever a worker or multiple workers are declared. This enables exporting Redis metrics
    to the built-in Prometheus service. SYNAPSE_METRICS is required.
  • SYNAPSE_ENABLE_POSTGRES_METRIC_EXPORT:
    If you are using a Postgresql Database, it can grab metrics from it as well. SYNAPSE_METRICS is required.
  • SYNAPSE_ENABLE_COMPRESSOR:
    The Matrix team made a database compressor that can make the state parts of the database less....sprawly? It's included by default. Add SYNAPSE_ENABLE_COMPRESSOR to run it as a cron job every sunday at 1am. Actual space saving will not occur until your next auto-vaccum run. POSTGRES_PASSWORD is required at minimum, all related postgres variables are recommended(username,host,port,databasename).
    Grafana dashboards are provided in the contrib directory of the source repo.
  • SYNAPSE_ENABLE_BUILTIN_COTURN:
    Enables the built-in coturn server. Configuration is automatically generated and put in turnserver.conf. Other options you can set related to this, but not the homeserver configuration are COTURN_MIN_PORT and COTURN_MAX_PORT, which default if not set to 49153 and 49173, respectively. And you can enable COTURN_METRICS so you can see those pretty(boring) graphs.

Tag summary

Content type

Image

Digest

sha256:90cbe7d70

Size

212.7 MB

Last updated

about 6 hours ago

docker pull realtyem/synapse