Compare commits
125 Commits
Author | SHA1 | Date | |
---|---|---|---|
af3c8fd252 | |||
40d6b1df4e | |||
0378e8d89f | |||
c542629264 | |||
005ce43f61
|
|||
bca2a983c0
|
|||
89892ed818 | |||
1b32621af9
|
|||
919e9253ae
|
|||
c71f3bc519
|
|||
e9b5a5360f
|
|||
1188f5d770 | |||
17ad6ac250
|
|||
1bcb2d83b2
|
|||
8ded1abe20
|
|||
6f3e135b1d
|
|||
02a9d526fd
|
|||
d5bde0c969
|
|||
29c4b53f40
|
|||
89bb7a9f58
|
|||
9c1bdb632b | |||
32b1f856b7
|
|||
c807a7813d
|
|||
f5275b2384
|
|||
ef7d74d102
|
|||
a8f43e725d
|
|||
fa101da24b
|
|||
98635cb612
|
|||
643eceae13
|
|||
64905ccc35
|
|||
965809ce11
|
|||
047dac8d21
|
|||
33d6f5819c
|
|||
96a28d62ca
|
|||
038f03d872
|
|||
37465d7baf
|
|||
d2db4622a6
|
|||
9800197803
|
|||
e13dee14bd
|
|||
ff78ac0aab
|
|||
85949eed2b
|
|||
e9748c1641
|
|||
2f294803ac
|
|||
fa503e1f1d
|
|||
8222f55f64
|
|||
9ddafdbbc6
|
|||
522b1ef917
|
|||
1763e0f749
|
|||
789d5d0745
|
|||
8ab11e14a8
|
|||
184252de29
|
|||
aa7357596a
|
|||
b4b867bf4f
|
|||
4daf9eecb3
|
|||
68d73bd4e7
|
|||
6727434db5
|
|||
85598331b7
|
|||
0c0c1d6052
|
|||
7094f51810
|
|||
e8a876a28c
|
|||
17d116c600
|
|||
d53efd82b9
|
|||
fd76821803
|
|||
e2d21764f1
|
|||
daf4fcb02e
|
|||
4f936a594a
|
|||
10e459f183
|
|||
650e0cbc28
|
|||
a5f9105613
|
|||
b2a29da9a3
|
|||
b7cce0a516
|
|||
93ae4d6c8a
|
|||
1ec30af608
|
|||
dc6146c597
|
|||
87df9c99c6
|
|||
867c07f88f | |||
1b1cdf4af2 | |||
68f18336d7 | |||
012a93a689 | |||
bbb28ff6c2 | |||
a79a2aa2d8 | |||
c1ad176dfc | |||
627a0b6a01 | |||
44836c713a | |||
92ff8ebcb7 | |||
4aca0bbf14 | |||
a0aea386a4 | |||
7238f765b1 | |||
03bbade383 | |||
6da0caae76 | |||
107737c377 | |||
84574ff569 | |||
56f2323bbb | |||
f7b95a6687 | |||
a2e22e4a54 | |||
2952c623a1 | |||
74f7a698aa | |||
7aed440d97 | |||
aca1a644d9 | |||
241b8bd7ff | |||
3c74eccfa1 | |||
b704f7aceb | |||
c0bde0b431 | |||
d968f064af | |||
d8307ad2bf | |||
d9ed3f07be | |||
f98f61063a | |||
714f11df3b | |||
c1c6ece1dc | |||
1f01929ed8 | |||
fbb5b5a984 | |||
e695bea733 | |||
9420ca82ec | |||
6f383f2c3a | |||
31d1aba393 | |||
bc7d4c3c92 | |||
e66832b78a | |||
93c6214959 | |||
e490ccbfca | |||
139c4ecfc4 | |||
52af3d76ae | |||
8a20bddd41 | |||
6f0999895f | |||
a75a19a120 | |||
28c64539da |
64
.env.sample
Normal file
64
.env.sample
Normal file
@ -0,0 +1,64 @@
|
||||
TYPE=matrix-synapse
|
||||
|
||||
DOMAIN=matrix.example.com
|
||||
LETS_ENCRYPT_ENV=production
|
||||
|
||||
SECRET_DB_PASSWORD_VERSION=v1
|
||||
|
||||
SYNAPSE_ADMIN_EMAIL=admin@example.com
|
||||
|
||||
SECRET_REGISTRATION_SHARED_SECRET_VERSION=v1
|
||||
SECRET_MACAROON_SECRET_KEY_VERSION=v1
|
||||
SECRET_FORM_SECRET_VERSION=v1
|
||||
|
||||
COMPOSE_FILE="compose.yml"
|
||||
|
||||
#DISABLE_FEDERATION=1
|
||||
|
||||
# Set "true" to enable federation endpoint on $DOMAIN/.well-known/matrix/server
|
||||
SERVE_SERVER_WELLKNOWN=false
|
||||
|
||||
ENABLE_REGISTRATION=false
|
||||
PASSWORD_LOGIN_ENABLED=true
|
||||
|
||||
#AUTO_JOIN_ROOM_ENABLED=1
|
||||
#AUTO_JOIN_ROOM="#example:example.com"
|
||||
|
||||
SQL_LOG_LEVEL=WARN
|
||||
ROOT_LOG_LEVEL=WARN
|
||||
|
||||
REDACTION_RETENTION_PERIOD=7d
|
||||
|
||||
RETENTION_MAX_LIFETIME=1m
|
||||
|
||||
ENABLE_3PID_LOOKUP=true
|
||||
|
||||
USER_IPS_MAX_AGE=1d
|
||||
|
||||
ENCRYPTED_BY_DEFAULT=all
|
||||
|
||||
#ENABLE_ALLOWLIST=1
|
||||
#FEDERATION_ALLOWLIST="[]"
|
||||
|
||||
#COMPOSE_FILE="compose.yml:compose.keycloak.yml"
|
||||
#KEYCLOAK_ENABLED=1
|
||||
#KEYCLOAK_NAME=
|
||||
#KEYCLOAK_URL=
|
||||
#KEYCLOAK_CLIENT_ID=
|
||||
#KEYCLOAK_CLIENT_DOMAIN=
|
||||
#SECRET_KEYCLOAK_CLIENT_SECRET_VERSION=v1
|
||||
|
||||
#COMPOSE_FILE="compose.yml:compose.turn.yml"
|
||||
#TURN_ENABLED=1
|
||||
#TURN_URIS="[\"turns:coturn.foo.zone?transport=udp\", \"turns:coturn.foo.zone?transport=tcp\"]"
|
||||
#TURN_ALLOW_GUESTS=true
|
||||
#SECRET_TURN_SHARED_SECRET_VERSION=v1
|
||||
|
||||
#COMPOSE_FILE="compose.yml:compose.smtp.yml"
|
||||
#SMTP_ENABLED=1
|
||||
#SMTP_APP_NAME=
|
||||
#SMTP_FROM=
|
||||
#SMTP_HOST=
|
||||
#SMTP_PORT=
|
||||
#SMTP_USER=
|
||||
#SECRET_SMTP_PASSWORD_VERSION=v1
|
@ -1,6 +0,0 @@
|
||||
export DOMAIN=matrix.example.com
|
||||
export STACK_NAME=matrix
|
||||
|
||||
export LETS_ENCRYPT_ENV=production
|
||||
|
||||
export ENTRYPOINT_CONF_VERSION=v1
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/.envrc
|
||||
.envrc
|
||||
synapse
|
||||
|
93
README.md
93
README.md
@ -1,18 +1,81 @@
|
||||
# Matrix Synapse
|
||||
# Matrix (Synapse)
|
||||
|
||||
Matrix Synapse, based on the [official `matrixdotorg/synapse`
|
||||
image][synapse-docker].
|
||||
<!-- metadata -->
|
||||
|
||||
1. Set up Docker Swarm and [`abra`][abra]
|
||||
2. Deploy [`compose-stacks/traefik`][compose-traefik]
|
||||
2. `cp .envrc.sample .envrc`
|
||||
3. Edit `.envrc` - be sure to change `$DOMAIN` to something that resolves to
|
||||
your Docker swarm box
|
||||
4. `direnv allow` (or `. .envrc`)
|
||||
5. `abra deploy`
|
||||
6. `abra service_run synapse` to open a shell
|
||||
7. `register_new_matrix_user -c /data/homeserver.yaml http://localhost:8008`
|
||||
* **Category**: Apps
|
||||
* **Status**: 0, work-in-progress
|
||||
* **Image**: [`matrixdotorg/synapse`](https://hub.docker.com/r/matrixdotorg/synapse), 4, upstream
|
||||
* **Healthcheck**: Yes
|
||||
* **Backups**: No
|
||||
* **Email**: Yes
|
||||
* **Tests**: No
|
||||
* **SSO**: Yes
|
||||
|
||||
[synapse-docker]: https://hub.docker.com/r/matrixdotorg/synapse
|
||||
[abra]: https://git.autonomic.zone/autonomic-cooperative/abra
|
||||
[compose-traefik]: https://git.autonomic.zone/compose-stacks/traefik
|
||||
<!-- endmetadata -->
|
||||
|
||||
## Basic usage
|
||||
|
||||
1. Set up Docker Swarm and [`abra`](https://docs.coopcloud.tech/abra/)
|
||||
2. Deploy [`coop-cloud/traefik`](https://git.coopcloud.tech/coop-cloud/traefik)
|
||||
3. `abra app new matrix-synapse --secrets` (optionally with `--pass` if you'd like to save secrets in `pass`)
|
||||
4. `abra app YOURAPPDOMAIN config` - be sure to change `$DOMAIN` to something that resolves to your Docker swarm box
|
||||
5. `abra app YOURAPPDOMAIN deploy`
|
||||
6. Create an initial user: `abra app YOURAPPDOMAIN run app register_new_matrix_user -c /data/homeserver.yaml http://localhost:8008`
|
||||
|
||||
## Tips & Tricks
|
||||
|
||||
### Disabling federation
|
||||
|
||||
> We're not sure this does it exactly and there is still a discussion running
|
||||
> upstrem about whether this is the right way to do it & whether it could be
|
||||
> more convenient. We welcome issues / change sets to close up more federation
|
||||
> functionality.
|
||||
|
||||
- use `DISABLE_FEDERATION=1` to turn off federation listeners
|
||||
- don't use [`compose.matrix.yml`](https://git.coopcloud.tech/coop-cloud/traefik/src/branch/master/compose.matrix.yml) in your traefik config to keep the federation ports closed
|
||||
|
||||
### Enabling federation
|
||||
|
||||
See [`#27`](https://git.coopcloud.tech/coop-cloud/matrix-synapse/pulls/27) for more.
|
||||
|
||||
Depending on your setup, using `SERVE_SERVER_WELLKNOWN=true` might work to start federating.
|
||||
|
||||
### Seeing what changed in `homeserver.yaml` between versions
|
||||
|
||||
Change the version range to suit your needs.
|
||||
|
||||
```
|
||||
git clone https://github.com/matrix-org/synapse
|
||||
cd synapse/docs
|
||||
git log --follow -p v1.48.0..v1.51.0 sample_config.yaml
|
||||
```
|
||||
|
||||
### Generating a new `homeserver.yaml`
|
||||
|
||||
The default is also available to see [here](https://matrix-org.github.io/synapse/latest/usage/configuration/homeserver_sample_config.html).
|
||||
|
||||
```
|
||||
docker run -it \
|
||||
--entrypoint="" \
|
||||
-e SYNAPSE_SERVER_NAME=foo.com \
|
||||
-e SYNAPSE_REPORT_STATS=no \
|
||||
matrixdotorg/synapse:v1.48.0 \
|
||||
sh -c '/start.py generate; cat /data/homeserver.yaml' > homeserver.yaml.tmpl`
|
||||
```
|
||||
|
||||
### Generating a new `<server>.log.config`
|
||||
|
||||
```
|
||||
docker run -it \
|
||||
--entrypoint="" \
|
||||
-e SYNAPSE_SERVER_NAME=foo.com \
|
||||
-e SYNAPSE_REPORT_STATS=no \
|
||||
matrixdotorg/synapse:v1.48.0 \
|
||||
sh -c '/start.py generate; cat /data/foo.com.log.config' > log.config
|
||||
```
|
||||
|
||||
### Getting client discovery on a custom domain
|
||||
|
||||
You'll need to deploy something like [this](https://git.autonomic.zone/ruangrupa/well-known-uris).
|
||||
|
||||
This could be implemented in this recipe but we haven't merged it in yet. Chang sets are welcome.
|
||||
|
3
abra.sh
Normal file
3
abra.sh
Normal file
@ -0,0 +1,3 @@
|
||||
export ENTRYPOINT_CONF_VERSION=v1
|
||||
export HOMESERVER_YAML_VERSION=v8
|
||||
export LOG_CONFIG_VERSION=v2
|
22
compose.keycloak.yml
Normal file
22
compose.keycloak.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
secrets:
|
||||
- db_password
|
||||
- form_secret
|
||||
- keycloak_client_secret
|
||||
- macaroon_secret_key
|
||||
- registration_shared_secret
|
||||
environment:
|
||||
- KEYCLOAK_CLIENT_DOMAIN
|
||||
- KEYCLOAK_CLIENT_ID
|
||||
- KEYCLOAK_ENABLED
|
||||
- KEYCLOAK_NAME
|
||||
- KEYCLOAK_URL
|
||||
|
||||
secrets:
|
||||
keycloak_client_secret:
|
||||
external: true
|
||||
name: ${STACK_NAME}_keycloak_client_secret_${SECRET_KEYCLOAK_CLIENT_SECRET_VERSION}
|
17
compose.keycloak2.yml
Normal file
17
compose.keycloak2.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
secrets:
|
||||
- keycloak2_client_secret
|
||||
environment:
|
||||
- KEYCLOAK2_CLIENT_ID
|
||||
- KEYCLOAK2_ENABLED
|
||||
- KEYCLOAK2_NAME
|
||||
- KEYCLOAK2_URL
|
||||
|
||||
secrets:
|
||||
keycloak2_client_secret:
|
||||
external: true
|
||||
name: ${STACK_NAME}_keycloak2_client_secret_${SECRET_KEYCLOAK2_CLIENT_SECRET_VERSION}
|
23
compose.smtp.yml
Normal file
23
compose.smtp.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
secrets:
|
||||
- db_password
|
||||
- form_secret
|
||||
- macaroon_secret_key
|
||||
- registration_shared_secret
|
||||
- smtp_password
|
||||
environment:
|
||||
- SMTP_APP_NAME
|
||||
- SMTP_ENABLED
|
||||
- SMTP_FROM
|
||||
- SMTP_HOST
|
||||
- SMTP_PORT
|
||||
- SMTP_USER
|
||||
|
||||
secrets:
|
||||
smtp_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION}
|
20
compose.turn.yml
Normal file
20
compose.turn.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
secrets:
|
||||
- db_password
|
||||
- form_secret
|
||||
- macaroon_secret_key
|
||||
- registration_shared_secret
|
||||
- turn_shared_secret
|
||||
environment:
|
||||
- TURN_ALLOW_GUESTS
|
||||
- TURN_ENABLED
|
||||
- TURN_URIS
|
||||
|
||||
secrets:
|
||||
turn_shared_secret:
|
||||
external: true
|
||||
name: ${STACK_NAME}_turn_shared_secret_${SECRET_TURN_SHARED_SECRET_VERSION}
|
102
compose.yml
102
compose.yml
@ -2,38 +2,88 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
synapse:
|
||||
image: "matrixdotorg/synapse:latest"
|
||||
app:
|
||||
image: "matrixdotorg/synapse:v1.55.2"
|
||||
volumes:
|
||||
- "data:/data"
|
||||
secrets:
|
||||
- db_password
|
||||
- registration_shared_secret
|
||||
- macaroon_secret_key
|
||||
- form_secret
|
||||
environment:
|
||||
- ENCRYPTED_BY_DEFAULT
|
||||
- AUTO_JOIN_ROOM
|
||||
- AUTO_JOIN_ROOM_ENABLED
|
||||
- DISABLE_FEDERATION
|
||||
- DOMAIN
|
||||
- ENABLE_3PID_LOOKUP
|
||||
- ENABLE_ALLOWLIST
|
||||
- ENABLE_REGISTRATION
|
||||
- FEDERATION_ALLOWLIST
|
||||
- LETSENCRYPT_HOST=${DOMAIN}
|
||||
- PASSWORD_LOGIN_ENABLED
|
||||
- REDACTION_RETENTION_PERIOD
|
||||
- ROOT_LOG_LEVEL
|
||||
- SERVE_SERVER_WELLKNOWN
|
||||
- SQL_LOG_LEVEL
|
||||
- STACK_NAME
|
||||
- SYNAPSE_ADMIN_EMAIL
|
||||
- SYNAPSE_REPORT_STATS=no
|
||||
- SYNAPSE_SERVER_NAME=${DOMAIN}
|
||||
- USER_IPS_MAX_AGE
|
||||
- VIRTUAL_HOST=${DOMAIN}
|
||||
- VIRTUAL_PORT=8008
|
||||
- LETSENCRYPT_HOST=${DOMAIN}
|
||||
- SYNAPSE_SERVER_NAME=${DOMAIN}
|
||||
- SYNAPSE_REPORT_STATS=no
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
configs:
|
||||
- source: homeserver_yaml
|
||||
target: /data/homeserver.yaml
|
||||
- source: log_config
|
||||
target: /data/log.config
|
||||
- source: entrypoint_conf
|
||||
target: /docker-entrypoint.sh
|
||||
mode: 0555
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8008"
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: "60s"
|
||||
max_attempts: 3
|
||||
window: 120s
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
configs:
|
||||
- source: entrypoint_conf
|
||||
target: /docker-entrypoint.sh
|
||||
mode: 0555
|
||||
- "coop-cloud.${STACK_NAME}.version=1.3.0+v1.55.2"
|
||||
|
||||
db:
|
||||
image: postgres:13-alpine
|
||||
secrets:
|
||||
- db_password
|
||||
environment:
|
||||
- LC_COLLATE=C
|
||||
- LC_CTYPE=C
|
||||
- POSTGRES_DB=synapse
|
||||
- POSTGRES_INITDB_ARGS="-E \"UTF8\""
|
||||
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
|
||||
- POSTGRES_USER=synapse
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-U", "synapse"]
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
deploy:
|
||||
labels:
|
||||
backupbot.backup: "true"
|
||||
backupbot.backup.pre-hook: "mkdir -p /tmp/backup/ && PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /tmp/backup/backup.sql"
|
||||
backupbot.backup.post-hook: "rm -rf /tmp/backup"
|
||||
backupbot.backup.path: "/tmp/backup/"
|
||||
|
||||
volumes:
|
||||
data:
|
||||
postgres:
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
@ -45,3 +95,25 @@ configs:
|
||||
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_CONF_VERSION}
|
||||
file: entrypoint.sh.tmpl
|
||||
template_driver: golang
|
||||
homeserver_yaml:
|
||||
name: ${STACK_NAME}_homserver_yaml_${HOMESERVER_YAML_VERSION}
|
||||
file: homeserver.yaml.tmpl
|
||||
template_driver: golang
|
||||
log_config:
|
||||
name: ${STACK_NAME}_log_config_${LOG_CONFIG_VERSION}
|
||||
file: log.config.tmpl
|
||||
template_driver: golang
|
||||
|
||||
secrets:
|
||||
db_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
|
||||
registration_shared_secret:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_REGISTRATION_SHARED_SECRET_VERSION}
|
||||
macaroon_secret_key:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_MACAROON_SECRET_KEY_VERSION}
|
||||
form_secret:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_FORM_SECRET_VERSION}
|
||||
|
@ -1,7 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -f /data/homeserver.yaml ]]; then
|
||||
/start.py generate
|
||||
# https://github.com/matrix-org/synapse/tree/develop/docker#running-synapse
|
||||
# default user permissions for the synapse user
|
||||
chown 991:991 /data
|
||||
|
||||
if [[ ! -f /data/{{ env "DOMAIN" }}.signing.key ]]; then
|
||||
/start.py generate
|
||||
fi
|
||||
|
||||
/start.py
|
||||
|
2632
homeserver.yaml.tmpl
Normal file
2632
homeserver.yaml.tmpl
Normal file
File diff suppressed because it is too large
Load Diff
20
log.config.tmpl
Normal file
20
log.config.tmpl
Normal file
@ -0,0 +1,20 @@
|
||||
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.storage.SQL:
|
||||
level: {{ env "SQL_LOG_LEVEL" }}
|
||||
|
||||
root:
|
||||
level: {{ env "ROOT_LOG_LEVEL" }}
|
||||
handlers: [console]
|
||||
|
||||
disable_existing_loggers: false
|
6
release/1.3.0+v1.55.2
Normal file
6
release/1.3.0+v1.55.2
Normal file
@ -0,0 +1,6 @@
|
||||
The deployment failed due to the app/db getting confused. I think this is just
|
||||
due to the recipe not having good healthcheck config. After the app container
|
||||
flapped a bit, everything came up nicely. d1 @ autonomic co-op.
|
||||
|
||||
Same thing happened to me when deploying this for another instance. Also d1 @
|
||||
autonomic co-op.
|
Reference in New Issue
Block a user