Move matrix-bridge-mautrix-hangouts to its own container network

This commit is contained in:
Slavi Pantaleev 2024-01-07 15:37:04 +02:00
parent 6723fcd6d5
commit 142de83b41
9 changed files with 196 additions and 76 deletions

View File

@ -1082,27 +1082,51 @@ matrix_mautrix_googlechat_database_password: "{{ '%s' | format(matrix_homeserver
# We don't enable bridges by default. # We don't enable bridges by default.
matrix_mautrix_hangouts_enabled: false matrix_mautrix_hangouts_enabled: false
matrix_mautrix_hangouts_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}" matrix_mautrix_hangouts_systemd_required_services_list_auto: |
matrix_mautrix_hangouts_systemd_required_services_list: |
{{ {{
['docker.service'] matrix_addons_homeserver_systemd_services_list
+ +
['matrix-' + matrix_homeserver_implementation + '.service'] ([devture_postgres_identifier ~ '.service'] if (devture_postgres_enabled and matrix_mautrix_hangouts_database_hostname == devture_postgres_connection_hostname) else [])
+
([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled else [])
+
(['matrix-nginx-proxy.service'] if matrix_nginx_proxy_enabled else [])
}} }}
matrix_mautrix_hangouts_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'ho.as.token', rounds=655555) | to_uuid }}" matrix_mautrix_hangouts_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}"
matrix_mautrix_hangouts_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'ho.hs.token', rounds=655555) | to_uuid }}"
matrix_mautrix_hangouts_container_http_host_bind_port: "{{ (matrix_playbook_service_host_bind_interface_prefix ~ '9007') if matrix_playbook_service_host_bind_interface_prefix else '' }}" matrix_mautrix_hangouts_container_http_host_bind_port: "{{ (matrix_playbook_service_host_bind_interface_prefix ~ '9007') if matrix_playbook_service_host_bind_interface_prefix else '' }}"
matrix_mautrix_hangouts_container_network: "{{ matrix_addons_container_network }}"
matrix_mautrix_hangouts_container_additional_networks_auto: |-
{{
(
([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network])
+
([devture_postgres_container_network] if (devture_postgres_enabled and matrix_mautrix_hangouts_database_hostname == devture_postgres_connection_hostname and matrix_mautrix_hangouts_container_network != devture_postgres_container_network) else [])
+
([matrix_playbook_reverse_proxyable_services_additional_network] if (matrix_playbook_reverse_proxyable_services_additional_network and matrix_mautrix_gmessages_container_labels_traefik_enabled) else [])
) | unique
}}
matrix_mautrix_hangouts_container_labels_traefik_enabled: "{{ matrix_playbook_reverse_proxy_type in ['playbook-managed-traefik', 'other-traefik-container'] }}"
matrix_mautrix_hangouts_container_labels_traefik_docker_network: "{{ matrix_playbook_reverse_proxyable_services_additional_network }}"
matrix_mautrix_hangouts_container_labels_traefik_entrypoints: "{{ devture_traefik_entrypoint_primary }}"
matrix_mautrix_hangouts_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certResolver_primary }}"
matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_enabled: "{{ matrix_metrics_exposure_http_basic_auth_enabled }}"
matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_users: "{{ matrix_metrics_exposure_http_basic_auth_users }}"
matrix_mautrix_hangouts_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'ho.as.token', rounds=655555) | to_uuid }}"
matrix_mautrix_hangouts_homeserver_address: "{{ matrix_addons_homeserver_client_api_url }}"
matrix_mautrix_hangouts_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'ho.hs.token', rounds=655555) | to_uuid }}"
matrix_mautrix_hangouts_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}" matrix_mautrix_hangouts_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}"
matrix_mautrix_hangouts_metrics_enabled: "{{ prometheus_enabled }}"
matrix_mautrix_hangouts_metrics_proxying_enabled: "{{ matrix_mautrix_hangouts_metrics_enabled and matrix_metrics_exposure_enabled }}"
matrix_mautrix_hangouts_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}"
matrix_mautrix_hangouts_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/mautrix-hangouts"
# Postgres is the default, except if not using internal Postgres server # Postgres is the default, except if not using internal Postgres server
matrix_mautrix_hangouts_database_engine: "{{ 'postgres' if devture_postgres_enabled else 'sqlite' }}" matrix_mautrix_hangouts_database_engine: "{{ 'postgres' if devture_postgres_enabled else 'sqlite' }}"
matrix_mautrix_hangouts_database_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}" matrix_mautrix_hangouts_database_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}"

View File

@ -6,7 +6,7 @@ matrix_mautrix_hangouts_enabled: true
matrix_mautrix_hangouts_container_image_self_build: false matrix_mautrix_hangouts_container_image_self_build: false
matrix_mautrix_hangouts_container_image_self_build_repo: "https://github.com/mautrix/hangouts.git" matrix_mautrix_hangouts_container_image_self_build_repo: "https://github.com/mautrix/hangouts.git"
matrix_mautrix_hangouts_container_image_self_build_repo_version: "{{ 'master' if matrix_mautrix_hangouts_version == 'latest' else matrix_mautrix_googlechat_version }}" matrix_mautrix_hangouts_container_image_self_build_repo_version: "{{ 'master' if matrix_mautrix_hangouts_version == 'latest' else matrix_mautrix_hangouts_version }}"
# renovate: datasource=docker depName=dock.mau.dev/mautrix/hangouts # renovate: datasource=docker depName=dock.mau.dev/mautrix/hangouts
matrix_mautrix_hangouts_version: latest matrix_mautrix_hangouts_version: latest
@ -22,7 +22,7 @@ matrix_mautrix_hangouts_docker_src_files_path: "{{ matrix_mautrix_hangouts_base_
matrix_mautrix_hangouts_public_endpoint: '/mautrix-hangouts' matrix_mautrix_hangouts_public_endpoint: '/mautrix-hangouts'
matrix_mautrix_hangouts_homeserver_address: "{{ matrix_homeserver_container_url }}" matrix_mautrix_hangouts_homeserver_address: ""
matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}' matrix_mautrix_hangouts_homeserver_domain: '{{ matrix_domain }}'
matrix_mautrix_hangouts_appservice_address: 'http://matrix-mautrix-hangouts:8080' matrix_mautrix_hangouts_appservice_address: 'http://matrix-mautrix-hangouts:8080'
@ -39,11 +39,59 @@ matrix_mautrix_hangouts_bridge_permissions: |
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:9007"), or empty string to not expose. # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:9007"), or empty string to not expose.
matrix_mautrix_hangouts_container_http_host_bind_port: '' matrix_mautrix_hangouts_container_http_host_bind_port: ''
matrix_mautrix_hangouts_container_network: ""
matrix_mautrix_hangouts_container_additional_networks: "{{ matrix_mautrix_hangouts_container_additional_networks_auto + matrix_mautrix_hangouts_container_additional_networks_custom }}"
matrix_mautrix_hangouts_container_additional_networks_auto: []
matrix_mautrix_hangouts_container_additional_networks_custom: []
# matrix_mautrix_hangouts_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container.
# See `../templates/labels.j2` for details.
#
# To inject your own other container labels, see `matrix_mautrix_hangouts_container_labels_additional_labels`.
matrix_mautrix_hangouts_container_labels_traefik_enabled: true
matrix_mautrix_hangouts_container_labels_traefik_docker_network: "{{ matrix_mautrix_hangouts_container_network }}"
matrix_mautrix_hangouts_container_labels_traefik_entrypoints: web-secure
matrix_mautrix_hangouts_container_labels_traefik_tls_certResolver: default # noqa var-naming
# Controls whether labels will be added that expose mautrix-googlechat's public endpoint
matrix_mautrix_hangouts_container_labels_public_endpoint_enabled: true
matrix_mautrix_hangouts_container_labels_public_endpoint_hostname: ""
matrix_mautrix_hangouts_container_labels_public_endpoint_path_prefix: "{{ matrix_mautrix_hangouts_public_endpoint }}"
matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_rule: "Host(`{{ matrix_mautrix_hangouts_container_labels_public_endpoint_hostname }}`) && PathPrefix(`{{ matrix_mautrix_hangouts_container_labels_public_endpoint_path_prefix }}`)"
matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_priority: 0
matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_entrypoints: "{{ matrix_mautrix_hangouts_container_labels_traefik_entrypoints }}"
matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_tls: "{{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_entrypoints != 'web' }}"
matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_tls_certResolver: "{{ matrix_mautrix_hangouts_container_labels_traefik_tls_certResolver }}" # noqa var-naming
# Controls whether labels will be added that expose mautrix-googlechat's metrics
matrix_mautrix_hangouts_container_labels_metrics_enabled: "{{ matrix_mautrix_hangouts_metrics_enabled and matrix_mautrix_hangouts_metrics_proxying_enabled }}"
matrix_mautrix_hangouts_container_labels_metrics_traefik_rule: "Host(`{{ matrix_mautrix_hangouts_metrics_proxying_hostname }}`) && PathPrefix(`{{ matrix_mautrix_hangouts_metrics_proxying_path_prefix }}`)"
matrix_mautrix_hangouts_container_labels_metrics_traefik_priority: 0
matrix_mautrix_hangouts_container_labels_metrics_traefik_entrypoints: "{{ matrix_mautrix_hangouts_container_labels_traefik_entrypoints }}"
matrix_mautrix_hangouts_container_labels_metrics_traefik_tls: "{{ matrix_mautrix_hangouts_container_labels_metrics_traefik_entrypoints != 'web' }}"
matrix_mautrix_hangouts_container_labels_metrics_traefik_tls_certResolver: "{{ matrix_mautrix_hangouts_container_labels_traefik_tls_certResolver }}" # noqa var-naming
matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_enabled: false
# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users
matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_users: ''
# matrix_mautrix_hangouts_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
# See `../templates/labels.j2` for details.
#
# Example:
# matrix_mautrix_hangouts_container_labels_additional_labels: |
# my.label=1
# another.label="here"
matrix_mautrix_hangouts_container_labels_additional_labels: ''
# A list of extra arguments to pass to the container # A list of extra arguments to pass to the container
matrix_mautrix_hangouts_container_extra_arguments: [] matrix_mautrix_hangouts_container_extra_arguments: []
# List of systemd services that matrix-mautrix-hangouts.service depends on. # List of systemd services that matrix-mautrix-hangouts.service depends on.
matrix_mautrix_hangouts_systemd_required_services_list: ['docker.service'] matrix_mautrix_hangouts_systemd_required_services_list: "{{ matrix_mautrix_hangouts_systemd_required_services_list_default + matrix_mautrix_hangouts_systemd_required_services_list_auto + matrix_mautrix_hangouts_systemd_required_services_list_custom }}"
matrix_mautrix_hangouts_systemd_required_services_list_default: ['docker.service']
matrix_mautrix_hangouts_systemd_required_services_list_auto: []
matrix_mautrix_hangouts_systemd_required_services_list_custom: []
# List of systemd services that matrix-mautrix-hangouts.service wants # List of systemd services that matrix-mautrix-hangouts.service wants
matrix_mautrix_hangouts_systemd_wanted_services_list: [] matrix_mautrix_hangouts_systemd_wanted_services_list: []
@ -51,6 +99,15 @@ matrix_mautrix_hangouts_systemd_wanted_services_list: []
matrix_mautrix_hangouts_appservice_token: '' matrix_mautrix_hangouts_appservice_token: ''
matrix_mautrix_hangouts_homeserver_token: '' matrix_mautrix_hangouts_homeserver_token: ''
# Whether or not metrics endpoint should be enabled.
# Enabling them is usually enough for a local (in-container) Prometheus to consume them.
# If metrics need to be consumed by another (external) Prometheus server, consider exposing them via `matrix_mautrix_hangouts_metrics_proxying_enabled`.
matrix_mautrix_hangouts_metrics_enabled: false
# Controls whether metrics should be proxied (exposed) on a public URL.
matrix_mautrix_hangouts_metrics_proxying_enabled: false
matrix_mautrix_hangouts_metrics_proxying_hostname: ''
matrix_mautrix_hangouts_metrics_proxying_path_prefix: ''
# Database-related configuration fields. # Database-related configuration fields.
# #

View File

@ -1,44 +0,0 @@
---
- name: Fail if matrix-nginx-proxy role already executed
ansible.builtin.fail:
msg: >-
Trying to append Mautrix Hangouts's reverse-proxying configuration to matrix-nginx-proxy,
but it's pointless since the matrix-nginx-proxy role had already executed.
To fix this, please change the order of roles in your playbook,
so that the matrix-nginx-proxy role would run after the matrix-bridge-mautrix-hangouts role.
when: matrix_nginx_proxy_role_executed | default(False) | bool
- name: Generate Mautrix Hangouts proxying configuration for matrix-nginx-proxy
ansible.builtin.set_fact:
matrix_mautrix_hangouts_matrix_nginx_proxy_configuration: |
location {{ matrix_mautrix_hangouts_public_endpoint }} {
{% if matrix_nginx_proxy_enabled | default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #}
resolver 127.0.0.11 valid=5s;
set $backend "matrix-mautrix-hangouts:8080";
proxy_pass http://$backend;
{% else %}
{# Generic configuration for use outside of our container setup #}
proxy_pass http://127.0.0.1:9007;
{% endif %}
}
- name: Register Mautrix Hangouts proxying configuration with matrix-nginx-proxy
ansible.builtin.set_fact:
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
{{
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
+
[matrix_mautrix_hangouts_matrix_nginx_proxy_configuration]
}}
- name: Warn about reverse-proxying if matrix-nginx-proxy not used
ansible.builtin.debug:
msg: >-
NOTE: You've enabled the Mautrix Hangouts bridge but are not using the matrix-nginx-proxy
reverse proxy.
Please make sure that you're proxying the `{{ matrix_mautrix_hangouts_public_endpoint }}`
URL endpoint to the matrix-mautrix-hangouts container.
You can expose the container's port using the `matrix_mautrix_hangouts_container_http_host_bind_port` variable.
when: "matrix_mautrix_hangouts_enabled | bool and not matrix_nginx_proxy_enabled | default(False) | bool"

View File

@ -1,14 +1,5 @@
--- ---
- tags:
- setup-all
- setup-nginx-proxy
- install-all
- install-nginx-proxy
block:
- when: matrix_mautrix_hangouts_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/inject_into_nginx_proxy.yml"
- tags: - tags:
- setup-all - setup-all
- setup-mautrix-hangouts - setup-mautrix-hangouts

View File

@ -113,6 +113,21 @@
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure mautrix-hangouts support files installed
ansible.builtin.template:
src: "{{ role_path }}/templates/{{ item }}.j2"
dest: "{{ matrix_mautrix_hangouts_base_path }}/{{ item }}"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- labels
- name: Ensure matrix-mautrix-hangouts container network is created
community.general.docker_network:
name: "{{ matrix_mautrix_hangouts_container_network }}"
driver: bridge
- name: Ensure matrix-mautrix-hangouts.service installed - name: Ensure matrix-mautrix-hangouts.service installed
ansible.builtin.template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-mautrix-hangouts.service.j2" src: "{{ role_path }}/templates/systemd/matrix-mautrix-hangouts.service.j2"

View File

@ -9,4 +9,10 @@
- {'name': 'matrix_mautrix_hangouts_public_endpoint', when: true} - {'name': 'matrix_mautrix_hangouts_public_endpoint', when: true}
- {'name': 'matrix_mautrix_hangouts_appservice_token', when: true} - {'name': 'matrix_mautrix_hangouts_appservice_token', when: true}
- {'name': 'matrix_mautrix_hangouts_homeserver_token', when: true} - {'name': 'matrix_mautrix_hangouts_homeserver_token', when: true}
- {'name': 'matrix_mautrix_hangouts_homeserver_address', when: true}
- {'name': 'matrix_mautrix_hangouts_database_hostname', when: "{{ matrix_mautrix_hangouts_database_engine == 'postgres' }}"} - {'name': 'matrix_mautrix_hangouts_database_hostname', when: "{{ matrix_mautrix_hangouts_database_engine == 'postgres' }}"}
- {'name': 'matrix_mautrix_hangouts_container_network', when: true}
- {'name': 'matrix_mautrix_hangouts_metrics_proxying_hostname', when: "{{ matrix_mautrix_hangouts_metrics_enabled }}"}
- {'name': 'matrix_mautrix_hangouts_metrics_proxying_path_prefix', when: "{{ matrix_mautrix_hangouts_metrics_enabled }}"}
- {'name': 'matrix_mautrix_hangouts_container_labels_public_endpoint_hostname', when: "{{ matrix_mautrix_hangouts_container_labels_public_endpoint_enabled }}"}
- {'name': 'matrix_mautrix_hangouts_container_labels_public_endpoint_path_prefix', when: "{{ matrix_mautrix_hangouts_container_labels_public_endpoint_enabled }}"}

View File

@ -42,6 +42,11 @@ appservice:
as_token: "{{ matrix_mautrix_hangouts_appservice_token }}" as_token: "{{ matrix_mautrix_hangouts_appservice_token }}"
hs_token: "{{ matrix_mautrix_hangouts_homeserver_token }}" hs_token: "{{ matrix_mautrix_hangouts_homeserver_token }}"
# Prometheus telemetry config. Requires prometheus-client to be installed.
metrics:
enabled: {{ matrix_mautrix_hangouts_metrics_enabled | to_json }}
listen_port: 8000
# Bridge config # Bridge config
bridge: bridge:
# Localpart template of MXIDs for Hangouts users. # Localpart template of MXIDs for Hangouts users.

View File

@ -0,0 +1,55 @@
{% if matrix_mautrix_hangouts_container_labels_traefik_enabled %}
traefik.enable=true
{% if matrix_mautrix_hangouts_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_mautrix_hangouts_container_labels_traefik_docker_network }}
{% endif %}
{#
Public
#}
{% if matrix_mautrix_hangouts_container_labels_public_endpoint_enabled %}
traefik.http.routers.matrix-mautrix-hangouts-public.rule={{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_rule }}
{% if matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.matrix-mautrix-hangouts-public.priority={{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-mautrix-hangouts-public.service=matrix-mautrix-hangouts-public
traefik.http.routers.matrix-mautrix-hangouts-public.entrypoints={{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_entrypoints }}
traefik.http.routers.matrix-mautrix-hangouts-public.tls={{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_tls | to_json }}
{% if matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_tls %}
traefik.http.routers.matrix-mautrix-hangouts-public.tls.certResolver={{ matrix_mautrix_hangouts_container_labels_public_endpoint_traefik_tls_certResolver }}
{% endif %}
traefik.http.services.matrix-mautrix-hangouts-public.loadbalancer.server.port=8080
{% endif %}
{#
/Public
#}
{#
Metrics
#}
{% if matrix_mautrix_hangouts_container_labels_metrics_enabled %}
traefik.http.routers.matrix-mautrix-hangouts-metrics.rule={{ matrix_mautrix_hangouts_container_labels_metrics_traefik_rule }}
{% if matrix_mautrix_hangouts_container_labels_metrics_traefik_priority | int > 0 %}
traefik.http.routers.matrix-mautrix-hangouts-metrics.priority={{ matrix_mautrix_hangouts_container_labels_metrics_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-mautrix-hangouts-metrics.service=matrix-mautrix-hangouts-metrics
traefik.http.routers.matrix-mautrix-hangouts-metrics.entrypoints={{ matrix_mautrix_hangouts_container_labels_metrics_traefik_entrypoints }}
traefik.http.routers.matrix-mautrix-hangouts-metrics.tls={{ matrix_mautrix_hangouts_container_labels_metrics_traefik_tls | to_json }}
{% if matrix_mautrix_hangouts_container_labels_metrics_traefik_tls %}
traefik.http.routers.matrix-mautrix-hangouts-metrics.tls.certResolver={{ matrix_mautrix_hangouts_container_labels_metrics_traefik_tls_certResolver }}
{% endif %}
{% if matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_enabled %}
traefik.http.routers.matrix-mautrix-hangouts-metrics.middlewares=matrix-mautrix-hangouts-metrics-basic-auth
traefik.http.middlewares.matrix-mautrix-hangouts-metrics-basic-auth.basicauth.users={{ matrix_mautrix_hangouts_container_labels_metrics_middleware_basic_auth_users }}
{% endif %}
traefik.http.services.matrix-mautrix-hangouts-metrics.loadbalancer.server.port=8000
{% endif %}
{#
/Metrics
#}
{% endif %}
{{ matrix_mautrix_hangouts_container_labels_additional_labels }}

View File

@ -15,35 +15,46 @@ Type=simple
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}" Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mautrix-hangouts matrix-mautrix-hangouts-db 2>/dev/null || true' ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mautrix-hangouts matrix-mautrix-hangouts-db 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mautrix-hangouts matrix-mautrix-hangouts-db 2>/dev/null || true' ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mautrix-hangouts matrix-mautrix-hangouts-db 2>/dev/null || true'
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-mautrix-hangouts-db \ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} run \
--rm \
--name=matrix-mautrix-hangouts-db \
--log-driver=none \ --log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \ --cap-drop=ALL \
--network={{ matrix_docker_network }} \ --network={{ matrix_mautrix_hangouts_container_network }} \
-v {{ matrix_mautrix_hangouts_config_path }}:/config:z \ --mount type=bind,src={{ matrix_mautrix_hangouts_config_path }},dst=/config \
-v {{ matrix_mautrix_hangouts_data_path }}:/data:z \ --mount type=bind,src={{ matrix_mautrix_hangouts_data_path }},dst=/data \
{{ matrix_mautrix_hangouts_docker_image }} \ {{ matrix_mautrix_hangouts_docker_image }} \
alembic -x config=/config/config.yaml upgrade head alembic -x config=/config/config.yaml upgrade head
# Intentional delay, so that the homeserver (we likely depend on) can manage to start. # Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5 ExecStartPre={{ matrix_host_command_sleep }} 5
ExecStart={{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-mautrix-hangouts \ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \
--name=matrix-mautrix-hangouts \
--log-driver=none \ --log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \ --cap-drop=ALL \
--network={{ matrix_docker_network }} \ --network={{ matrix_mautrix_hangouts_container_network }} \
{% if matrix_mautrix_hangouts_container_http_host_bind_port %} {% if matrix_mautrix_hangouts_container_http_host_bind_port %}
-p {{ matrix_mautrix_hangouts_container_http_host_bind_port }}:8080 \ -p {{ matrix_mautrix_hangouts_container_http_host_bind_port }}:8080 \
{% endif %} {% endif %}
-v {{ matrix_mautrix_hangouts_config_path }}:/config:z \ --mount type=bind,src={{ matrix_mautrix_hangouts_config_path }},dst=/config \
-v {{ matrix_mautrix_hangouts_data_path }}:/data:z \ --mount type=bind,src={{ matrix_mautrix_hangouts_data_path }},dst=/data \
--label-file={{ matrix_mautrix_hangouts_base_path }}/labels \
{% for arg in matrix_mautrix_hangouts_container_extra_arguments %} {% for arg in matrix_mautrix_hangouts_container_extra_arguments %}
{{ arg }} \ {{ arg }} \
{% endfor %} {% endfor %}
{{ matrix_mautrix_hangouts_docker_image }} \ {{ matrix_mautrix_hangouts_docker_image }} \
python3 -m mautrix_hangouts -c /config/config.yaml --no-update python3 -m mautrix_hangouts -c /config/config.yaml --no-update
{% for network in matrix_mautrix_hangouts_container_additional_networks %}
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-mautrix-hangouts
{% endfor %}
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-mautrix-hangouts
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mautrix-hangouts 2>/dev/null || true' ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-mautrix-hangouts 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mautrix-hangouts 2>/dev/null || true' ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-mautrix-hangouts 2>/dev/null || true'
Restart=always Restart=always