Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 3 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,49 +100,9 @@ make generate-emoji

## Local Development with Matrix Synapse

For local development and testing, you can run a Matrix Synapse server using Docker Compose.

### Prerequisites

1. Install and configure the Mattermost Matrix Bridge plugin first
- **Matrix Server URL**: `http://localhost:8888`
2. Generate the bridge registration file through the plugin configuration
3. Copy the generated registration file to `docker/mattermost-bridge-registration.yaml`

### Starting the Matrix Synapse Server

1. Start the services:

```bash
docker-compose up -d
```

2. Create an admin user:

```bash
docker exec -it mattermost-plugin-matrix-bridge-synapse-1 register_new_matrix_user -c /data/homeserver.yaml -u admin -p admin123 -a http://localhost:8008
```

3. The Matrix server will be available at `http://localhost:8888`

### Configuration Notes

- The Synapse server is configured to use PostgreSQL as the database
- Registration is enabled for development purposes
- App service configuration is loaded from `docker/mattermost-bridge-registration.yaml`
- Room list publication is restricted to the bridge user only

### Stopping the Services

```bash
docker-compose down
```

To completely reset (remove all data):

```bash
docker-compose down -v
```
For local development and testing, you can run one or two Matrix Synapse servers using
Docker Compose. See **[docs/local-development.md](docs/local-development.md)** for the full
guide, including multi-server testing and connecting channels to a second homeserver.

## Troubleshooting

Expand Down
74 changes: 74 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,26 @@ services:
ports:
- "8888:8008"
- "8448:8448"
# Lets the container reach the Mattermost server running on the host (the
# registration file's `url` points at host.docker.internal). Docker Desktop
# (Mac/Windows) provides this automatically; host-gateway makes it work on
# Linux too.
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- synapse-init
- postgres

element:
image: vectorim/element-web:latest
restart: unless-stopped
ports:
- "8880:80"
volumes:
- ./docker/element-config.json:/app/config.json:ro
depends_on:
- synapse

postgres:
image: postgres:14
restart: unless-stopped
Expand All @@ -41,6 +57,64 @@ services:
volumes:
- postgres-data:/var/lib/postgresql/data

# --- Second Matrix homeserver, for manual multi-server testing ---
# server_name "synapse2.localhost" resolves to 127.0.0.1 (*.localhost) and is
# a distinct hostname from the first server, so the plugin derives a distinct
# serverID for it. Inject it into the plugin with `/matrix server add`.
synapse2-init:
image: alpine:latest
command: |
sh -c "
chown -R 991:991 /data
chmod -R 755 /data
"
volumes:
- synapse2-data:/data

synapse2:
image: matrixdotorg/synapse:latest
restart: unless-stopped
environment:
- SYNAPSE_SERVER_NAME=synapse2.localhost
- SYNAPSE_REPORT_STATS=no
- UID=991
- GID=991
volumes:
- synapse2-data:/data
- ./docker/synapse2_config.yaml:/data/homeserver.yaml:ro
- ./docker/mattermost-bridge-registration2.yaml:/data/mattermost-bridge-registration.yaml:ro
ports:
- "8889:8008"
- "8449:8448"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- synapse2-init
- postgres2

element2:
image: vectorim/element-web:latest
restart: unless-stopped
ports:
- "8881:80"
volumes:
- ./docker/element2-config.json:/app/config.json:ro
depends_on:
- synapse2

postgres2:
image: postgres:14
restart: unless-stopped
environment:
- POSTGRES_DB=synapse
- POSTGRES_USER=synapse
- POSTGRES_PASSWORD=synapse
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
volumes:
- postgres2-data:/var/lib/postgresql/data

volumes:
synapse-data:
postgres-data:
synapse2-data:
postgres2-data:
13 changes: 13 additions & 0 deletions docker/element-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"default_server_config": {
"m.homeserver": {
"base_url": "http://localhost:8888",
"server_name": "localhost"
}
},
"disable_custom_urls": false,
"disable_guests": false,
"brand": "Element (dev)",
"default_country_code": "US",
"show_labs_settings": true
}
13 changes: 13 additions & 0 deletions docker/element2-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"default_server_config": {
"m.homeserver": {
"base_url": "http://synapse2.localhost:8889",
"server_name": "synapse2.localhost"
}
},
"disable_custom_urls": false,
"disable_guests": false,
"brand": "Element (dev, synapse2)",
"default_country_code": "US",
"show_labs_settings": true
}
25 changes: 25 additions & 0 deletions docker/mattermost-bridge-registration2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
id: "mattermost-bridge"
url: "http://host.docker.internal:8065/plugins/com.mattermost.plugin-matrix-bridge"
# Each homeserver must present a UNIQUE hs_token: the plugin routes inbound
# Application Service traffic to the right server by matching this token.
as_token: "syn2_5Kd9WmXpQ2rLtVnB7cYhFgJ4sZaEuNi"
hs_token: "syn2_Tb3Rk8VpMxWq6NcYdL2fHgJ7sUaZ0eYi"
sender_localpart: "_mattermost_bridge"
namespaces:
users:
- exclusive: true
regex: "@_mattermost_.*:synapse2.localhost"
aliases:
- exclusive: true
regex: "#_mattermost_.*:synapse2.localhost"
- exclusive: false
regex: "#mattermost-bridge-.*:synapse2.localhost"
rooms:
- exclusive: false
regex: "!.*:synapse2.localhost"
rate_limited: false
protocols: ["mattermost"]
de.sorunome.msc2409.push_ephemeral: true
permissions:
- "m.room.directory"
- "m.room.membership"
70 changes: 70 additions & 0 deletions docker/synapse2_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
server_name: "synapse2.localhost"
pid_file: /data/homeserver.pid
public_baseurl: http://synapse2.localhost:8889/

listeners:
- port: 8008
tls: false
type: http
x_forwarded: true
resources:
- names: [client, federation]
compress: false

database:
name: psycopg2
args:
user: synapse
password: synapse
database: synapse
host: postgres2
port: 5432
cp_min: 5
cp_max: 10

log:
version: 1
formatters:
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: precise
loggers:
synapse:
level: INFO
synapse.access:
level: INFO
root:
level: INFO
handlers: [console]

media_store_path: "/data/media_store"
max_upload_size: 50M
max_image_pixels: 32M

registration_shared_secret: "development_secret_key_change_in_production"
macaroon_secret_key: "development_macaroon_secret_change_in_production"
form_secret: "development_form_secret_change_in_production"

signing_key_path: "/data/signing.key"

trusted_key_servers:
- server_name: "matrix.org"

enable_registration: true
enable_registration_without_verification: true

suppress_key_server_warning: true

room_list_publication_rules:
- user_id: "@_mattermost_bridge:synapse2.localhost"
action: allow
- user_id: "*"
action: deny

app_service_config_files:
- /data/mattermost-bridge-registration.yaml

report_stats: false
Loading
Loading