2023-10-23 14:12:45 +00:00
|
|
|
# Matrix Homeserver on fly.io
|
|
|
|
|
|
|
|
Quick notes on how to run [dendrite] for a small scale Matrix homeserver on [fly.io] with sqlite storage.
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
- A domain name where you can create/change A, AAAA and SRV records
|
|
|
|
- A [fly.io] account and the [`flyctl`] cli installed
|
|
|
|
- Docker or similar container runtime installed
|
|
|
|
|
|
|
|
## Preparations
|
|
|
|
|
|
|
|
For federation (talking to other homeservers), your server needs is a matrix server key.
|
|
|
|
|
2023-10-25 14:50:32 +00:00
|
|
|
Generate the server key using either the dendrite container:
|
2023-10-23 14:12:45 +00:00
|
|
|
|
2023-10-25 14:50:32 +00:00
|
|
|
```shell
|
|
|
|
docker run --rm -it -v $(pwd):/key -w /key --entrypoint /usr/bin/generate-keys matrixdotorg/dendrite-monolith:latest --private-key matrix_key.pem
|
2023-10-23 14:12:45 +00:00
|
|
|
```
|
2023-10-25 14:50:32 +00:00
|
|
|
|
|
|
|
or the `generate-keys` app:
|
|
|
|
```shell
|
|
|
|
go run github.com/matrix-org/dendrite/cmd/generate-keys \
|
|
|
|
--private-key=matrix_key.pem \
|
|
|
|
--tls-cert=server.crt \
|
|
|
|
--tls-key=server.key
|
2023-10-23 14:12:45 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
**Do not loose this key!**
|
|
|
|
|
2023-10-25 14:50:32 +00:00
|
|
|
Next, make copy the `dendrite-sample.in.yaml` to `dentrite.in.yaml` and change the `global.server_name` to your desired domain.
|
2023-10-23 14:12:45 +00:00
|
|
|
|
|
|
|
Finally, change the `app = "dendrite-on-fly"` line in `fly.toml` to an app name of your desire.
|
|
|
|
|
|
|
|
## Deployment
|
|
|
|
|
2023-10-25 14:50:32 +00:00
|
|
|
Choose your Fly.io region (`flyctl platform regions`) and edit the `fly.toml`
|
|
|
|
file.
|
|
|
|
Create a 10GB persistent volume mount in your desired region.
|
2023-10-23 14:12:45 +00:00
|
|
|
|
2023-10-25 14:50:32 +00:00
|
|
|
```shell
|
|
|
|
flyctl volumes create dendrite_data --region bos --size 10
|
2023-10-23 14:12:45 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Now you simply can deploy dendrite using
|
|
|
|
|
|
|
|
```
|
|
|
|
flyctl deploy
|
|
|
|
```
|
2023-10-25 14:50:32 +00:00
|
|
|
|
|
|
|
## Secrets
|
|
|
|
|
|
|
|
```shell
|
|
|
|
flyctl secrets set "DATABASE_URL=postgresql://user:pass@hostname/database?params=..."
|
2023-10-25 14:55:53 +00:00
|
|
|
flyctl secrets set "REGISTRATION_SHARED_SECRET=imabad5cret!"
|
2023-10-25 14:50:32 +00:00
|
|
|
base64 -w0 matrix_key.pem | flyctl secrets set MATRIX_KEY_PEM=-
|
|
|
|
```
|
2023-10-23 14:12:45 +00:00
|
|
|
|
|
|
|
## Domain configuration
|
|
|
|
|
|
|
|
After deployment, execute `flyctl info` to obtain the IP addresses your app runs on.
|
|
|
|
|
|
|
|
Use these IPs to create A and AAAA records for the domain name you configured in `dendrite.yaml`
|
|
|
|
|
|
|
|
Usually matrix federates on port 8448, but it is possible to use a SRV record to specify a different port (8443 in our case).
|
|
|
|
|
|
|
|
Create a SRV record at `_matrix._tcp.<the-original-domain>` with values `10 10 8443 <the-original-domain>`
|
|
|
|
|
|
|
|
It is possible to test federation with the [Matrix federation tester](https://federationtester.matrix.org/).
|
|
|
|
|
|
|
|
Once you have set up the A and AAAA records, obtain a TLS certificate using `flyctl`
|
|
|
|
|
|
|
|
```
|
|
|
|
flyctl certs add <hostname>
|
|
|
|
```
|
|
|
|
|
|
|
|
You now can create accounts on your homeserver and start chatting with people.
|
|
|
|
|
|
|
|
## Still to figure out
|
|
|
|
|
|
|
|
- How to backup your sqlite file
|
|
|
|
|
|
|
|
## Useful information
|
|
|
|
|
|
|
|
- flyctl v0.0.181 and dendrite v0.3.11 were used
|
|
|
|
|
|
|
|
[dendrite]: https://github.com/matrix-org/dendrite
|
|
|
|
[fly.io]: https://fly.io
|
|
|
|
[`flyctl`]: https://github.com/superfly/flyctl/releases
|