matrix-docker-ansible-deploy/roles/custom/matrix-static-files/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

84 lines
4.8 KiB
Django/Jinja

{% if matrix_static_files_container_labels_traefik_enabled %}
traefik.enable=true
{% if matrix_static_files_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_static_files_container_labels_traefik_docker_network }}
{% endif %}
traefik.http.services.{{ matrix_static_files_identifier }}.loadbalancer.server.port={{ matrix_static_files_environment_variable_server_port }}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_enabled %}
############################################################
# #
# Related to /.well-known/matrix on the matrix domain #
# #
############################################################
{% set well_known_matrix_endpoint_middlewares = [] %}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_enabled %}
traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-compress.compress=true
traefik.http.middlewares.{{ matrix_static_files_identifier }}-well-known-compress.compress.minResponseBodyBytes={{ matrix_static_files_container_labels_well_known_matrix_endpoint_middleware_compress_minResponseBodyBytes }}
{% set well_known_matrix_endpoint_middlewares = well_known_matrix_endpoint_middlewares + [matrix_static_files_identifier + '-well-known-compress'] %}
{% endif %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.rule={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_rule }}
{% if well_known_matrix_endpoint_middlewares | length > 0 %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.middlewares={{ well_known_matrix_endpoint_middlewares | join(',') }}
{% endif %}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.priority={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority }}
{% endif %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.service={{ matrix_static_files_identifier }}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.entrypoints={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_entrypoints }}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.tls={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls | to_json }}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls %}
traefik.http.routers.{{ matrix_static_files_identifier }}-well-known.tls.certResolver={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls_certResolver }}
{% endif %}
############################################################
# #
# /Related to /.well-known/matrix on the matrix domain #
# #
############################################################
{% endif %}
{% if matrix_static_files_container_labels_base_domain_enabled %}
############################################################
# #
# Base domain serving #
# #
############################################################
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.rule={{ matrix_static_files_container_labels_base_domain_traefik_rule }}
{% if matrix_static_files_container_labels_base_domain_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.priority={{ matrix_static_files_container_labels_base_domain_traefik_priority }}
{% endif %}
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.service={{ matrix_static_files_identifier }}
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.entrypoints={{ matrix_static_files_container_labels_base_domain_traefik_entrypoints }}
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.tls={{ matrix_static_files_container_labels_base_domain_traefik_tls | to_json }}
{% if matrix_static_files_container_labels_base_domain_traefik_tls %}
traefik.http.routers.{{ matrix_static_files_identifier }}-base-domain.tls.certResolver={{ matrix_static_files_container_labels_base_domain_traefik_tls_certResolver }}
{% endif %}
############################################################
# #
# /Base domain serving #
# #
############################################################
{% endif %}
{% endif %}
{{ matrix_static_files_container_labels_additional_labels }}