feat(service): add Matrix service (#6029)

This commit is contained in:
Nicanor Alexander de la Cruz Caba
2025-07-18 15:39:11 -04:00
committed by GitHub
parent f14858ebee
commit fea7544300
2 changed files with 137 additions and 0 deletions

7
public/svgs/matrix.svg Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 520 520" style="enable-background:new 0 0 520 520;" xml:space="preserve">
<path d="M13.7,11.9v496.2h35.7V520H0V0h49.4v11.9H13.7z"/>
<path d="M166.3,169.2v25.1h0.7c6.7-9.6,14.8-17,24.2-22.2c9.4-5.3,20.3-7.9,32.5-7.9c11.7,0,22.4,2.3,32.1,6.8 c9.7,4.5,17,12.6,22.1,24c5.5-8.1,13-15.3,22.4-21.5c9.4-6.2,20.6-9.3,33.5-9.3c9.8,0,18.9,1.2,27.3,3.6c8.4,2.4,15.5,6.2,21.5,11.5 c6,5.3,10.6,12.1,14,20.6c3.3,8.5,5,18.7,5,30.7v124.1h-50.9V249.6c0-6.2-0.2-12.1-0.7-17.6c-0.5-5.5-1.8-10.3-3.9-14.3 c-2.2-4.1-5.3-7.3-9.5-9.7c-4.2-2.4-9.9-3.6-17-3.6c-7.2,0-13,1.4-17.4,4.1c-4.4,2.8-7.9,6.3-10.4,10.8c-2.5,4.4-4.2,9.4-5,15.1 c-0.8,5.6-1.3,11.3-1.3,17v103.3h-50.9v-104c0-5.5-0.1-10.9-0.4-16.3c-0.2-5.4-1.3-10.3-3.1-14.9c-1.8-4.5-4.8-8.2-9-10.9 c-4.2-2.7-10.3-4.1-18.5-4.1c-2.4,0-5.6,0.5-9.5,1.6c-3.9,1.1-7.8,3.1-11.5,6.1c-3.7,3-6.9,7.3-9.5,12.9c-2.6,5.6-3.9,13-3.9,22.1 v107.6h-50.9V169.2H166.3z"/>
<path d="M506.3,508.1V11.9h-35.7V0H520v520h-49.4v-11.9H506.3z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,130 @@
# documentation: https://matrix.org/docs/chat_basics/matrix-for-im/
# slogan: Chat securely with your family, friends, community, or build great apps with Matrix!
# tags: chat,slack,discord,voip,video,call
# logo: svgs/matrix.svg
services:
matrix:
image: matrixdotorg/synapse:latest
volumes:
- ./data:/data
environment:
- SERVICE_FQDN_MATRIX_8008
- SYNAPSE_SERVER_NAME=${SERVICE_URL_MATRIX}
- SYNAPSE_REPORT_STATS=no
- ENABLE_REGISTRATION=${ENABLE_REGISTRATION}
- RECAPTCHA_PUBLIC_KEY=${RECAPTCHA_PUBLIC_KEY}
- RECAPTCHA_PRIVATE_KEY=${RECAPTCHA_PRIVATE_KEY}
- _SERVER_NAME=${SERVICE_URL_MATRIX}
- _ADMIN_NAME=${SERVICE_USER_ADMIN}
- _ADMIN_PASS=${SERVICE_PASSWORD_ADMIN}
entrypoint:
- /bin/bash
- -c
- |
! test -f /data/homeserver.yaml && /start.py generate
# registration_shared_secret
grep "registration_shared_secret" /data/homeserver.yaml \
| awk '{print $2}' > ./registration_shared_secret
# macaroon_secret_key
grep "macaroon_secret_key" /data/homeserver.yaml \
| awk '{print $2}' > ./macaroon_secret_key
# form_secret
grep "form_secret" /data/homeserver.yaml \
| awk '{print $2}' > ./form_secret
##########################
# #
# homeserver.yaml: start #
# #
##########################
cat <<EOF > /data/homeserver.yaml
server_name: "${SERVICE_URL_MATRIX}"
pid_file: /data/homeserver.pid
# server
listeners:
- port: 8008
tls: false
type: http
x_forwarded: true
resources:
- names: [client, federation]
compress: false
# database
database:
name: sqlite3
args:
database: /data/homeserver.db
# general
log_config: "/data/${SERVICE_URL_MATRIX}.log.config"
media_store_path: /data/media_store
report_stats: false
# secrets
registration_shared_secret: $(<./registration_shared_secret)
macaroon_secret_key: $(<./macaroon_secret_key)
form_secret: $(<./form_secret)
signing_key_path: "/data/${SERVICE_URL_MATRIX}.signing.key"
#rooms
auto_join_rooms:
- "#general:${SERVICE_URL_MATRIX}"
# federation
trusted_key_servers:
- server_name: "matrix.org"
autocreate_auto_join_rooms_federated: false
allow_public_rooms_over_federation: false
EOF
########################
# #
# homeserver.yaml: end #
# #
########################
test -n "${ENABLE_REGISTRATION}" && ! grep "#registration" /data/homeserver.yaml &>/dev/null \
&& echo >> /data/homeserver.yaml \
&& cat <<EOF >> /data/homeserver.yaml
#registration
enable_registration: true # Allows users to register on your server.
EOF
! grep ${RECAPTCHA_PUBLIC_KEY} /data/homeserver.yaml &>/dev/null \
&& echo >> /data/homeserver.yaml \
&& cat <<EOF >> /data/homeserver.yaml
# reCAPTCHA settings
enable_registration_captcha: true # Enables CAPTCHA for registrations.
recaptcha_public_key: "${RECAPTCHA_PUBLIC_KEY}"
recaptcha_private_key: "${RECAPTCHA_PRIVATE_KEY}"
recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify"
EOF
register_admin(){
while ! curl -I localhost:8008 &>/dev/null; do
sleep 1
done
register_new_matrix_user \
-a \
-u ${SERVICE_USER_ADMIN} \
-p ${SERVICE_PASSWORD_ADMIN} \
-c /data/homeserver.yaml \
http://localhost:8008 &>/dev/null
}
register_admin &
/start.py
healthcheck:
test:
- CMD
- curl
- -I
- localhost:8008
interval: 5s
timeout: 3s
retries: 5