Skip to content
Jona Abdinghoff edited this page Jul 11, 2021 · 12 revisions

Suggestions on getting matrix-registration working in a docker container.

Pull the image

To get a stable pull an image from here:

Prepare image

When you are ready to start using it, tag it as :latest.

docker tag zeratax/matrix-registration:x.y.z matrix-registration:latest

Use the image to manage tokens

Create an empty folder as a base of operations. And cd into it.

Create an empty directory called "data". Copy config.sample.yaml into it as config.yaml. Set the config as needed and prefix the database with /data/.

db: 'sqlite:////data/db.sqlite3'

For docker you need to modify the host setting to listen on every interface, port needs to stay 5000

host: '0.0.0.0'
port: 5000

Also prefix the log file with "/data/".

filename: /data/m_reg.log

This is needed because the cwd inside the container is /. The sqlite database gets created but is not persisted over containers by using the volume.

Build an executable run.sh script outside the data folder.

#!/bin/sh

docker run \
  -it --rm \
  --user "$(id -u):$(id -g)" \
  --volume $(pwd)/data:/data  \
  matrix-registration:latest  \
  "$@"

Run ./run.sh --help to get help.

Run ./run.sh status and notice how db.sqlite3 gets created in the data folder.

Optionally any of these options before the image name for debugging.

  --env FLASK_ENV=development \
  --env FLASK_DEBUG=1  \
  --entrypoint sh  \

If using the entrypoint, notice that there's an executable /usr/local/bin/matrix-registration.

Use the image for registrations

Let's assume your synapse container was already started with --network matrix. If not see below.

In the config file set the server_location like this, where synapse is the name of the synapse container. You can probably also use https://synapse:8448 here if your synapse server is negotiating TLS.

server_location: 'http://synapse:8008'

Create an executable serve.sh script.

#!/bin/sh

docker run \
  -d \
  --user "$(id -u):$(id -g)" \
  --network matrix \
  --publish 5000:5000/tcp \
  --volume $(pwd)/data:/data \
  matrix-registration:latest \
  serve

Using a docker network

docker network create matrix

Optionally start your PostgreSQL database with --name db and --network matrix.

Start synapse with --network matrix and set the host of your database in homeserver.yaml to db (matching the container name).