Add native Traefik support to matrix-dendrite

This commit is contained in:
Slavi Pantaleev
2024-01-11 11:30:42 +02:00
parent f78adfde47
commit d8eb768e03
9 changed files with 269 additions and 25 deletions

View File

@ -0,0 +1,147 @@
{% if matrix_dendrite_container_labels_traefik_enabled %}
traefik.enable=true
{% if matrix_dendrite_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_dendrite_container_labels_traefik_docker_network }}
{% endif %}
traefik.http.services.matrix-dendrite.loadbalancer.server.port={{ matrix_dendrite_http_bind_port }}
{#
Root path (/)
#}
{% if matrix_dendrite_container_labels_client_root_enabled %}
{% set client_root_middlewares = [] %}
{% if matrix_dendrite_container_labels_client_root_redirection_enabled %}
{% set client_root_middlewares = client_root_middlewares + ['matrix-dendrite-client-root-redirect'] %}
traefik.http.middlewares.matrix-dendrite-client-root-redirect.redirectregex.regex=(.*)
traefik.http.middlewares.matrix-dendrite-client-root-redirect.redirectregex.replacement={{ matrix_dendrite_container_labels_client_root_redirection_url }}
{% endif %}
traefik.http.routers.matrix-dendrite-client-root.rule={{ matrix_dendrite_container_labels_client_root_traefik_rule }}
traefik.http.routers.matrix-dendrite-client-root.middlewares={{ client_root_middlewares | join(',') }}
{% if matrix_dendrite_container_labels_client_root_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-client-root.priority={{ matrix_dendrite_container_labels_client_root_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-client-root.service=matrix-dendrite
traefik.http.routers.matrix-dendrite-client-root.entrypoints={{ matrix_dendrite_container_labels_client_root_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-client-root.tls={{ matrix_dendrite_container_labels_client_root_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_client_root_traefik_tls %}
traefik.http.routers.matrix-dendrite-client-root.tls.certResolver={{ matrix_dendrite_container_labels_client_root_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Root path (/)
#}
{#
Client-API (/_matrix)
#}
{% if matrix_dendrite_container_labels_client_api_enabled %}
traefik.http.routers.matrix-dendrite-client-api.rule={{ matrix_dendrite_container_labels_client_api_traefik_rule }}
{% if matrix_dendrite_container_labels_client_api_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-client-api.priority={{ matrix_dendrite_container_labels_client_api_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-client-api.service=matrix-dendrite
traefik.http.routers.matrix-dendrite-client-api.entrypoints={{ matrix_dendrite_container_labels_client_api_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-client-api.tls={{ matrix_dendrite_container_labels_client_api_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_client_api_traefik_tls %}
traefik.http.routers.matrix-dendrite-client-api.tls.certResolver={{ matrix_dendrite_container_labels_client_api_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Client-API (/_matrix)
#}
{#
Synapse Admin API (/_synapse/admin)
#}
{% if matrix_dendrite_container_labels_client_synapse_admin_api_enabled %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.rule={{ matrix_dendrite_container_labels_client_synapse_admin_api_traefik_rule }}
{% if matrix_dendrite_container_labels_client_synapse_admin_api_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.priority={{ matrix_dendrite_container_labels_client_synapse_admin_api_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.service=matrix-dendrite
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.entrypoints={{ matrix_dendrite_container_labels_client_synapse_admin_api_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.tls={{ matrix_dendrite_container_labels_client_synapse_admin_api_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_client_synapse_admin_api_traefik_tls %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.tls.certResolver={{ matrix_dendrite_container_labels_client_synapse_admin_api_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Synapse Admin API (/_synapse/admin)
#}
{#
Dendrite Admin API (/_dendrite/admin)
#}
{% if matrix_dendrite_container_labels_client_dendrite_admin_api_enabled %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.rule={{ matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_rule }}
{% if matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.priority={{ matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.service=matrix-dendrite
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.entrypoints={{ matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.tls={{ matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_tls %}
traefik.http.routers.matrix-dendrite-client-synapse-admin-api.tls.certResolver={{ matrix_dendrite_container_labels_client_dendrite_admin_api_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Dendrite Admin API (/_dendrite/admin)
#}
{#
Federation-API (/_matrix)
#}
{% if matrix_dendrite_container_labels_federation_api_enabled %}
traefik.http.routers.matrix-dendrite-federation-api.rule={{ matrix_dendrite_container_labels_federation_api_traefik_rule }}
{% if matrix_dendrite_container_labels_federation_api_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-federation-api.priority={{ matrix_dendrite_container_labels_federation_api_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-federation-api.service=matrix-dendrite-federation-api
traefik.http.routers.matrix-dendrite-federation-api.entrypoints={{ matrix_dendrite_container_labels_federation_api_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-federation-api.tls={{ matrix_dendrite_container_labels_federation_api_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_federation_api_traefik_tls %}
traefik.http.routers.matrix-dendrite-federation-api.tls.certResolver={{ matrix_dendrite_container_labels_federation_api_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Federation-API (/_matrix)
#}
{% endif %}
{{ matrix_dendrite_container_labels_additional_labels }}

View File

@ -40,6 +40,7 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--mount type=bind,src={{ matrix_dendrite_config_dir_path }},dst=/data,ro \
--mount type=bind,src={{ matrix_dendrite_storage_path }},dst=/matrix-media-store-parent,bind-propagation=slave \
--mount type=bind,src={{ matrix_dendrite_nats_storage_path }},dst=/matrix-nats-store,bind-propagation=slave \
--label-file={{ matrix_dendrite_base_path }}/labels \
{% for volume in matrix_dendrite_container_additional_volumes %}
-v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \
{% endfor %}