matrix-docker-ansible-deploy/roles/custom/matrix-registration/templates/labels.j2
Slavi Pantaleev 48a4afb114 Make Traefik labels files look better
This moves the comments from being just in Jinja,
to actually ending up in the generated `labels` file,
which makes inspection of the final result easier.

Also, some new lines were added here and there to make labels
more legible.

The generated file may still include weird new-lines due to
various `if` statements yielding content or not, but that's not so ugly
anymore - now that we have proper start/end sections that are visible in
the final `labels` file.
2024-01-15 10:41:15 +02:00

64 lines
3.3 KiB
Django/Jinja

{% if matrix_registration_container_labels_traefik_enabled %}
traefik.enable=true
{% if matrix_registration_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_registration_container_labels_traefik_docker_network }}
{% endif %}
traefik.http.services.matrix-registration.loadbalancer.server.port=5000
{% if matrix_registration_container_labels_public_endpoint_enabled %}
############################################################
# #
# Public (e.g. /matrix-registration) #
# #
############################################################
{% set middlewares = [] %}
{% if matrix_registration_path_prefix != '/' %}
traefik.http.middlewares.matrix-registration-slashless-redirect-slashless.redirectregex.regex=({{ matrix_registration_path_prefix | quote }})$
traefik.http.middlewares.matrix-registration-slashless-redirect-slashless.redirectregex.replacement=${1}/
{% set middlewares = middlewares + ['matrix-registration-slashless-redirect-slashless'] %}
{% endif %}
# matrix-registration serves nothing at the root URL, so we redirect to /register instead.
traefik.http.middlewares.matrix-registration-slashless-redirect-root.redirectregex.regex=({{ matrix_registration_path_prefix | quote }}{{ '' if matrix_registration_path_prefix == '/' else '/' }})$
traefik.http.middlewares.matrix-registration-slashless-redirect-root.redirectregex.replacement=${1}register
{% set middlewares = middlewares + ['matrix-registration-slashless-redirect-root'] %}
{% if matrix_registration_path_prefix != '/' %}
traefik.http.middlewares.matrix-registration-strip-prefix.stripprefix.prefixes={{ matrix_registration_path_prefix }}
{% set middlewares = middlewares + ['matrix-registration-strip-prefix'] %}
{% endif %}
traefik.http.routers.matrix-registration-public.rule={{ matrix_registration_container_labels_public_endpoint_traefik_rule }}
{% if middlewares | length > 0 %}
traefik.http.routers.matrix-registration-public.middlewares={{ middlewares | join(',') }}
{% endif %}
{% if matrix_registration_container_labels_public_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.matrix-registration-public.priority={{ matrix_registration_container_labels_public_endpoint_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-registration-public.service=matrix-registration
traefik.http.routers.matrix-registration-public.entrypoints={{ matrix_registration_container_labels_public_endpoint_traefik_entrypoints }}
traefik.http.routers.matrix-registration-public.tls={{ matrix_registration_container_labels_public_endpoint_traefik_tls | to_json }}
{% if matrix_registration_container_labels_public_endpoint_traefik_tls %}
traefik.http.routers.matrix-registration-public.tls.certResolver={{ matrix_registration_container_labels_public_endpoint_traefik_tls_certResolver }}
{% endif %}
############################################################
# #
# /Public (e.g. /matrix-registration) #
# #
############################################################
{% endif %}
{% endif %}
{{ matrix_registration_container_labels_additional_labels }}