diff --git a/group_vars/all b/group_vars/all index eeedd724..08628c06 100644 --- a/group_vars/all +++ b/group_vars/all @@ -103,7 +103,7 @@ redirect_domain_mappings: - { source: "funkwhale.{{top_domain}}", target: "music.{{top_domain}}" } - { source: "pixelfed.{{top_domain}}", target: "picture.{{top_domain}}" } - { source: "pictures.{{top_domain}}", target: "picture.{{top_domain}}" } -- { source: "matrix.{{top_domain}}", target: "chat.{{top_domain}}" } +- { source: "element.{{top_domain}}", target: "chat.{{top_domain}}" } ## Docker Applications @@ -120,7 +120,8 @@ domain_mailu: "mail.{{top_domain}}" domain_mastodon: "microblog.{{top_domain}}" domains_mastodon_alternates: [] domain_matomo: "matomo.{{top_domain}}" -domain_matrix: "chat.{{top_domain}}" +domain_matrix_synapse: "matrix.{{top_domain}}" +domain_matrix_element: "chat.{{top_domain}}" domain_mediawiki: "wiki.{{top_domain}}" domain_nextcloud: "cloud.{{top_domain}}" domain_pixelfed: "picture.{{top_domain}}" @@ -138,3 +139,5 @@ version_mastodon: "latest" ### Role specific configuration pixelfed_app_name: "Pictures" + +top_domain: "localhost" diff --git a/roles/docker-matrix/README.md b/roles/docker-matrix/README.md index 3788a6ab..c9822937 100644 --- a/roles/docker-matrix/README.md +++ b/roles/docker-matrix/README.md @@ -34,6 +34,13 @@ Matrix is an open-source project that provides a protocol for secure, decentrali ``` docker-compose logs ``` +## Sources + +### Guides + +- https://cyberhost.uk/element-matrix-setup/ +- https://www.linode.com/docs/guides/how-to-install-the-element-chat-app/ +- https://hub.docker.com/r/vectorim/element-web ## Links to ChatGPT Conversations diff --git a/roles/docker-matrix/tasks/main.yml b/roles/docker-matrix/tasks/main.yml index e4e5d57d..e8106d0f 100644 --- a/roles/docker-matrix/tasks/main.yml +++ b/roles/docker-matrix/tasks/main.yml @@ -1,6 +1,15 @@ --- - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml + vars: + domain: "{{synapse_domain}}" + http_port: "{{synapse_http_port}}" + +- name: "include tasks nginx-docker-proxy-domain.yml" + include_tasks: nginx-docker-proxy-domain.yml + vars: + domain: "{{element_domain}}" + http_port: "{{element_http_port}}" - name: "create {{docker_compose_instance_directory}}" file: @@ -8,6 +17,12 @@ state: directory mode: 0755 +- name: add element-config.json + template: + src: "element-config.json.j2" + dest: "{{docker_compose_instance_directory}}element-config.json" + notify: recreate matrix + - name: add homeserver.yaml template: src: "homeserver.yaml.j2" @@ -17,13 +32,13 @@ - name: add log.config template: src: "log.config.j2" - dest: "{{docker_compose_instance_directory}}{{domain}}.log.config" + dest: "{{docker_compose_instance_directory}}{{synapse_domain}}.log.config" notify: recreate matrix # https://github.com/matrix-org/synapse/issues/6303 - name: set correct folder permissions command: - cmd: "docker run --rm --mount type=volume,src=matrix_synapse_data,dst=/data -e SYNAPSE_SERVER_NAME={{domain}} -e SYNAPSE_REPORT_STATS=no --entrypoint /bin/sh matrixdotorg/synapse:latest -c 'chown -vR 991:991 /data'" + cmd: "docker run --rm --mount type=volume,src=matrix_synapse_data,dst=/data -e SYNAPSE_SERVER_NAME={{synapse_domain}} -e SYNAPSE_REPORT_STATS=no --entrypoint /bin/sh matrixdotorg/synapse:latest -c 'chown -vR 991:991 /data'" - name: add docker-compose.yml template: diff --git a/roles/docker-matrix/templates/docker-compose.yml.j2 b/roles/docker-matrix/templates/docker-compose.yml.j2 index 1dd9c749..9ac05a5d 100644 --- a/roles/docker-matrix/templates/docker-compose.yml.j2 +++ b/roles/docker-matrix/templates/docker-compose.yml.j2 @@ -10,12 +10,12 @@ services: volumes: - synapse_data:/data - ./homeserver.yaml:/data/homeserver.yaml:ro - - ./{{domain}}.log.config:/data/{{domain}}.log.config:ro + - ./{{synapse_domain}}.log.config:/data/{{synapse_domain}}.log.config:ro environment: - - SYNAPSE_SERVER_NAME={{domain}} + - SYNAPSE_SERVER_NAME={{synapse_domain}} - SYNAPSE_REPORT_STATS=no ports: - - "127.0.0.1:{{http_port}}:8008" + - "127.0.0.1:{{synapse_http_port}}:8008" depends_on: - database database: @@ -35,6 +35,13 @@ services: interval: 10s timeout: 5s retries: 6 + element: + image: vectorim/element-web:latest + restart: unless-stopped + volumes: + - ./element-config.json:/app/config.json + ports: + - "127.0.0.1:{{element_http_port}}:80" # bridges #mautrix-telegram: diff --git a/roles/docker-matrix/templates/element-config.json.j2 b/roles/docker-matrix/templates/element-config.json.j2 new file mode 100644 index 00000000..618287df --- /dev/null +++ b/roles/docker-matrix/templates/element-config.json.j2 @@ -0,0 +1,59 @@ +{ + "default_server_config": { + "m.homeserver": { + "base_url": "https://{{domain_matrix_synapse}}", + "server_name": "{{domain_matrix_synapse}}" + }, + "m.identity_server": { + "base_url": "https://{{top_domain}}" + } + }, + "brand": "Element", + "integrations_ui_url": "https://scalar.vector.im/", + "integrations_rest_url": "https://scalar.vector.im/api", + "integrations_widgets_urls": [ + "https://scalar.vector.im/_matrix/integrations/v1", + "https://scalar.vector.im/api", + "https://scalar-staging.vector.im/_matrix/integrations/v1", + "https://scalar-staging.vector.im/api", + "https://scalar-staging.riot.im/scalar/api" + ], + "bug_report_endpoint_url": "https://element.io/bugreports/submit", + "uisi_autorageshake_app": "element-auto-uisi", + "show_labs_settings": true, + "room_directory": { + "servers": ["matrix.org", "gitter.im", "libera.chat"] + }, + "enable_presence_by_hs_url": { + "https://matrix.org": false, + "https://matrix-client.matrix.org": false + }, + "terms_and_conditions_links": [ + { + "url": "https://element.io/privacy", + "text": "Privacy Policy" + }, + { + "url": "https://element.io/cookie-policy", + "text": "Cookie Policy" + } + ], + "sentry": { + "dsn": "https://029a0eb289f942508ae0fb17935bd8c5@sentry.matrix.org/6", + "environment": "develop" + }, + "posthog": { + "project_api_key": "phc_Jzsm6DTm6V2705zeU5dcNvQDlonOR68XvX2sh1sEOHO", + "api_host": "https://posthog.element.io" + }, + "privacy_policy_url": "https://element.io/cookie-policy", + "features": { + "feature_video_rooms": true, + "feature_rust_crypto": true, + "feature_new_room_decoration_ui": true + }, + "element_call": { + "url": "https://call.element.dev" + }, + "map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx" +} \ No newline at end of file diff --git a/roles/docker-matrix/templates/homeserver.yaml.j2 b/roles/docker-matrix/templates/homeserver.yaml.j2 index 3c95afd4..81232ac3 100644 --- a/roles/docker-matrix/templates/homeserver.yaml.j2 +++ b/roles/docker-matrix/templates/homeserver.yaml.j2 @@ -1,4 +1,4 @@ -server_name: "{{domain}}" +server_name: "{{domain_matrix_synapse}}" pid_file: /data/homeserver.pid listeners: - port: 8008 @@ -17,12 +17,12 @@ database: host: database cp_min: 5 cp_max: 10 -log_config: "/data/{{domain}}.log.config" +log_config: "/data/{{domain_matrix_synapse}}.log.config" media_store_path: /data/media_store registration_shared_secret: "{{matrix_registration_shared_secret}}" report_stats: true macaroon_secret_key: "{{matrix_macaroon_secret_key}}" form_secret: "{{matrix_form_secret}}" -signing_key_path: "/data/{{domain}}.signing.key" +signing_key_path: "/data/{{domain_matrix_synapse}}.signing.key" trusted_key_servers: - server_name: "matrix.org" diff --git a/roles/docker-matrix/templates/log.config.j2 b/roles/docker-matrix/templates/log.config.j2 index b14b98df..e8a842b5 100644 --- a/roles/docker-matrix/templates/log.config.j2 +++ b/roles/docker-matrix/templates/log.config.j2 @@ -8,7 +8,7 @@ handlers: file: class: logging.handlers.RotatingFileHandler formatter: precise - filename: /data/{{ domain }}.homeserver.log + filename: /data/{{synapse_domain}}.homeserver.log maxBytes: 10485760 backupCount: 3 console: diff --git a/servers.yml b/servers.yml index a2d5e1dd..05a9f0fb 100644 --- a/servers.yml +++ b/servers.yml @@ -205,8 +205,10 @@ roles: - role: docker-matrix vars: - domain: "{{domain_matrix}}" - http_port: 8021 + synapse_domain: "{{domain_matrix_synapse}}" + synapse_http_port: 8021 + element_domain: "{{domain_matrix_element}}" + element_http_port: 8022 - name: setup akaunting hosts hosts: akaunting