12 Bridge setup with Docker
Kevin Liu edited this page 2020-05-06 11:37:49 -07:00

New in version 0.2.0

Requirements

  • Docker
  • A Matrix homeserver that supports application services (e.g. Synapse)
  • Telegram app ID and hash so the bridge can use the Telegram API
    • You can get these from my.telegram.org. Telegram will ask you to enter some information to identify a "new app". The new app you are registering is your instance of the mautrix-telegram bridge, so you can enter what you wish (but you must enter something).

Setup

Docker images are hosted on dock.mau.dev

  1. Create a directory for the bridge and cd into it: mkdir mautrix-telegram && cd mautrix-telegram.
    N.B. The docker image will chown its /data directory to UID 1337. The commands below mount the working directory as /data, so make sure you always run them in the correct directory.
  2. Pull the docker image with docker pull dock.mau.dev/tulir/mautrix-telegram:<version>. Replace <version> with the version you want to run (e.g. latest or v0.6.0).
  3. Run the container for the first time, so it can create a config file for you:
    docker run --rm -v `pwd`:/data:z dock.mau.dev/tulir/mautrix-telegram:<version>
    
  4. Update the config to your liking. Don't forget to change the address and domain to match those of your homeserver, as well as the appservice.address if the container is not exposed at localhost, and to enter your Telegram api_id and api_hash. Don't change the database URI if using SQLite. You likely also want to edit bridge.permissions to give yourself admin access. For example, to give admin access to the whole domain, it would be "example.com": admin
  5. Generate the appservice registration by running the container again, same command as above.
  6. Add the path to the registration file to your Synapse's homeserver.yaml under the app_service_config_files section: app_service_config_files: ["/path/to/your/mautrix-telegram/registration.yaml"]
  7. Restart Synapse to apply changes.
  8. Run the bridge:
    docker run --restart unless-stopped -p 29317:29317 -v `pwd`:/data:z dock.mau.dev/tulir/mautrix-telegram:<version>
    

Upgrading

  1. Pull the new version (setup step 1)
  2. Start the new version (setup step 7)

Docker compose

Create a directory as in step #0 and create docker-compose.yml that contains something like this:

version: "3.7"

services:
  mautrix-telegram:
    container_name: mautrix-telegram
    image: dock.mau.dev/tulir/mautrix-telegram:<version>
    restart: unless-stopped
    volumes:
    - .:/data

Use docker-compose up -d to start, docker-compose stop to stop and docker-compose pull to update.