diff --git a/public/svgs/matrix.svg b/public/svgs/matrix.svg new file mode 100644 index 000000000..bc41720a2 --- /dev/null +++ b/public/svgs/matrix.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/templates/compose/matrix.yaml b/templates/compose/matrix.yaml new file mode 100644 index 000000000..372ba57df --- /dev/null +++ b/templates/compose/matrix.yaml @@ -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 < /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 <> /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 <> /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