knowledge/technology/applications/web/Matrix.md

2.4 KiB

website obj rev
https://matrix.org/ application 2024-01-19

Matrix

Matrix is an open standard and communication protocol for real-time communication. It aims to make real-time communication work seamlessly between different service providers, in the way that standard Simple Mail Transfer Protocol email currently does for store-and-forward email service, by allowing users with accounts at one communications service provider to communicate with users of a different service provider via online chat, voice over IP, and videotelephony. It therefore serves a similar purpose to protocols like XMPP, but is not based on any existing communication protocol.

By default matrix is federated and every user is located at a home server (@user:matrix.example.org) and can communicate with other users or join rooms.

Setup

To setup a matrix server using dendrite follow these steps. As prerequisites you need a valid domain name.

Generate a key

mkdir -p ./config
docker run --rm --entrypoint="/usr/bin/generate-keys" -v $(pwd)/config:/mnt matrixdotorg/dendrite-monolith:latest -private-key /mnt/matrix_key.pem

Generate a config file

mkdir -p ./config
docker run --rm --entrypoint="/bin/sh" -v $(pwd)/config:/mnt matrixdotorg/dendrite-monolith:latest -c "/usr/bin/generate-config -dir /var/dendrite/ -db postgres://dendrite:itsasecret@postgres/dendrite?sslmode=disable -server YourDomainHere > /mnt/dendrite.yaml"

Administration

Create a new Account:
To create a new account, use this command inside the dendrite container:

/bin/create-account -config /path/to/dendrite.yaml -username USERNAME [-admin]

Docker-Compose

Start the docker compose service:

version: "3.4"

services:
  postgres:
    hostname: postgres
    image: postgres:15-alpine
    restart: always
    volumes:
      - ./db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_USER: dendrite
      POSTGRES_DATABASE: dendrite
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dendrite"]
      interval: 5s
      timeout: 5s
      retries: 5

  dendrite:
    image: matrixdotorg/dendrite-monolith:latest
    ports:
      - 8448:8008
    volumes:
      - ./config:/etc/dendrite
      - ./data:/var/dendrite
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped