Skip to content

Docker compose managed Synapse home server with Postgres and Element.

License

Notifications You must be signed in to change notification settings

jrf-systems/matrix-docker-compose

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

matrix-docker-compose

Docker compose managed Synapse home server with Postgres and Riot.

Docker Images

Requirements

  • Docker
  • docker-compose
  • A reverse proxy
  • Python 3 (for admin scripts)

Reverse Proxy

You will need to have a reverse proxy setup. I use a variant of jwilder/nginx-proxy.

Assuming you have some base domain, domain.com, and you want the matrix client to use matrix.domain.com and Element to be at element.domain.com, you will need the following from your reverse proxy:

  • Listen on 443 for matrix.domain.com and forward to the Synapse container (name: matrix-synapse) at port 8008
  • Listen on 8448 for domain.com and forward to the Synapse container (name: matrix-synapse) at port 8008
  • Listen on 443 for element.domain.com and forward to the Riot container (name: matrix-element) at port 80

See docs/reverse_proxy for Synapse docs on reverse proxying.

Initial Setup

Configuration

  1. Configure env files
    1. Copy samples/env to .env and set desired values
    2. Copy samples/{postgres|synapse|element}.env files to top level directory and set desired values
  2. Configure postgres synapse user
    1. Copy samples/init.sql to config/init.sql
    2. Add postrgres synapse user password in config/init.sql
  3. Configure Riot
    1. Copy samples/config.json to config/config.json
    2. Change desired settings
  4. Run setup/generate.sh
  5. Configure Synapse
    1. Copy config/generated/homeserver.yaml to config/homeserver.yaml
    2. Configure database section
    3. Make other desired changes (see sample)
  6. Configure Coturn
    1. Copy config/generated/turnserver.conf to config/turnserver.conf
    2. Add min-port=49152 and max-port=49300 or desired range
    3. Be sure to update the port ranges in docker-compose.yml if you change these values
    4. Make other desired changes to config/turnserver.conf

Initialize

  1. Run setup/init.sh
  2. Run docker-compose up -d

Create Admin User

  1. Register your user
  2. Make user an admin:
    1. docker-compose exec postgres bash
    2. psql -U postgress
    3. \c synapse
    4. UPDATE users SET admin = 1 WHERE name = '@foo:bar.com'

Configuration Examples

The following are the settings I have changed from the generated homeserver config.

  • public_baseurl: https://matrix.domain.com/
  • Keys under Listeners and value port: 8008:
    • bind_addresses: ['0.0.0.0']
  • admin_contact: 'mailto:[email protected]'
  • Keys under database:
    • name: psycopg2
    • Keys under args:
      • user: synapse
      • password: "changethisbadpassword"
      • database: synapse
      • host: postgres
      • cp_min: 5
      • cp_max: 10
  • enable_registration: true
    • This enables registration from your Riot client; set to false if you want to disable.
  • Values under registrations_require_3pid:
    • - email
  • disable_msisdn_registration: true
  • enable_3pid_lookup: true
  • Keys under email:
    • smtp_host: smtp.gmail.com
    • smtp_port: 587
    • smtp_user: "[email protected]"
    • smtp_pass: "gmailpassword"
    • require_transport_security: true
    • notif_from: "%(app)s Homeserver <[email protected]>"
    • app_name: "whatever"
    • enable_notifs: true
    • client_base_url: "https://element.domain.com"
  • Keys under push:
    • include_content: true
  • Keys under server_notices:
    • system_mxid_localpart: notices
    • system_mxid_display_name: "Server Notices"
    • room_name: "Server Notices"

Synapse Admin API

adm/synapseadm provides a convient command line wrapper around curling the Synapse admin API. This is written with Python 3.

Run adm/synapseadm --help to see available commands.

See docs/admin_api for additional Synapse admin API.

Reference

Synapse Docs

Element Docs

General Docs

About

Docker compose managed Synapse home server with Postgres and Element.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 78.3%
  • Shell 21.7%