Matrix Synapse custom homeserver deploy

 


In previous post Matrix server with self build Element-Web was described a procedure how to prepare Linux server with local docker images registry. Now we use prepared infrastructure to deploy Synapse server from custom docker image built from source.

Matrix is an open source project that publishes the Matrix open standard for secure, decentralized, real-time communication, and its Apache licensed reference implementations.

Synapse: Matrix homeserver implementation developed by the matrix.org core team written in Python 3/Twisted.

Get Synapse sources from github:

$ git clone https://github.com/matrix-org/synapse

Buildkit

Synapse docker image build using BuildKit: Build images with BuildKit

Download latest BuildKit release from github: BuildKit releases

Unpack release binary archive to ./bin local directory:

Start BuildKit service:

Add DOCKER_BUILDKIT environment variable to user profile:

Build docker image:

Check built image:

Build image with (e.g. Jenkins) automation shell command for pipeline. Build with repo:5000/mysynapse:latest tag:

date
cd /home/userrepo/synapse
export DOCKER_BUILDKIT=1
docker build -t repo:5000/mysynapse:latest -f docker/Dockerfile .
echo "Synapse build successful!"

Check built tagged image:

Push image to local registry:

$ docker push repo:5000/mysynapse:latest

Ansible playbook

Get matrix ansible deploy scripts from github:

Edit ansible synapse role script config:

Change remote host domain and IP in ansible inventory config file:

userrepo@repo:~/$ vim ./matrix-docker-ansible-deploy/inventory/hosts

Run ansible script locally to deploy matrix services on remote host:

Ansible script will connect to remote server over SSH using ssh access key. Option -K was added for request password to get sudo privileges on remote host.

The script will run several docker containers. Connections to TURN server, Proxy and DB are shown on picture below:


- Nginx web-server will be used as a reverse proxy to connect matrix clients from public Internet. 
- PostgreSQL DB store user data.
- Coturn server used to traverse NAT for VoIP/Video calls.





Comments

Popular posts from this blog

Matrix server with self build Element-Web

MX-ONE short installation and maintenance guide (Russian)

Mitel SIP-phone XML API configuration server on Python/Flask and registration on Asterisk PBX