{#
SPDX-FileCopyrightText: 2024 Slavi Pantaleev

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{% if matrix_zulip_bridge_container_labels_traefik_enabled %}
traefik.enable=true

{% if matrix_zulip_bridge_container_labels_traefik_docker_network %}
traefik.docker.network={{ matrix_zulip_bridge_container_labels_traefik_docker_network }}
{% endif %}

traefik.http.services.matrix-zulip-bridge.loadbalancer.server.port={{ matrix_zulip_bridge_container_http_port }}

{% set middlewares = [] %}

{% if matrix_zulip_bridge_container_labels_traefik_path_prefix != '/' %}
traefik.http.middlewares.matrix-bridge-zulip-strip-prefix.stripprefix.prefixes={{ matrix_zulip_bridge_container_labels_traefik_path_prefix }}
{% set middlewares = middlewares + ['matrix-bridge-zulip-strip-prefix'] %}
{% endif %}

{% if matrix_zulip_bridge_container_labels_traefik_media_enabled %}
##########################################################################
#                                                                        #
# Media                                                                  #
#                                                                        #
##########################################################################

traefik.http.routers.matrix-bridge-zulip-media.rule={{ matrix_zulip_bridge_container_labels_traefik_media_rule }}

{% if matrix_zulip_bridge_container_labels_traefik_media_priority | int > 0 %}
traefik.http.routers.matrix-bridge-zulip-media.priority={{ matrix_zulip_bridge_container_labels_traefik_media_priority }}
{% endif %}

{% if middlewares | length > 0 %}
traefik.http.routers.matrix-bridge-zulip-media.middlewares={{ middlewares | join(',') }}
{% endif %}

traefik.http.routers.matrix-bridge-zulip-media.service=matrix-bridge-zulip
traefik.http.routers.matrix-bridge-zulip-media.entrypoints={{ matrix_zulip_bridge_container_labels_traefik_entrypoints }}

traefik.http.routers.matrix-bridge-zulip-media.tls={{ matrix_zulip_bridge_container_labels_traefik_media_tls | to_json }}
{% if matrix_zulip_bridge_container_labels_traefik_media_entrypoints %}
traefik.http.routers.matrix-bridge-zulip-media.tls.certResolver={{ matrix_zulip_bridge_container_labels_traefik_media_tls_certResolver }}
{% endif %}

##########################################################################
#                                                                        #
# /Media                                                                 #
#                                                                        #
##########################################################################
{% endif %}


{% endif %}

{{ matrix_zulip_bridge_container_labels_additional_labels }}
