[WIP] Initial work on matrix-static-files role

This commit is contained in:
Slavi Pantaleev
2024-01-03 13:05:59 +02:00
parent 128a7b82d5
commit 065b70203d
21 changed files with 675 additions and 57 deletions

View File

@ -0,0 +1,7 @@
#jinja2: lstrip_blocks: "True"
[[advanced.headers]]
source = "/.well-known/matrix/*"
headers.Content-Type = "application/json"
headers.Access-Control-Allow-Origin = "*"
headers.Cache-Control = "max-age={{ matrix_static_files_files_cache_time_hours * 3600 }}"

View File

@ -0,0 +1,8 @@
SERVER_PORT={{ matrix_static_files_environment_variable_server_port }}
SERVER_LOG_LEVEL={{ matrix_static_files_environment_variable_server_log_level }}
SERVER_LOG_REMOTE_ADDRESS={{ 'true' if matrix_static_files_environment_variable_server_log_remote_address else 'false' }}
SERVER_CONFIG_FILE={{ matrix_static_files_environment_variable_server_config_file }}
{{ matrix_static_files_environment_variables_additional_variables }}

View File

@ -0,0 +1,42 @@
{% 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_ident }}.loadbalancer.server.port={{ matrix_static_files_environment_variable_server_port }}
{#
Related to /.well-known/matrix
#}
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_enabled %}
traefik.http.middlewares.{{ matrix_static_files_ident }}-well-known-endpoint-compress.compress=true
traefik.http.middlewares.{{ matrix_static_files_ident }}-well-known-endpoint-compress.compress.minResponseBodyBytes=100
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.rule={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_rule }}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.middlewares={{ matrix_static_files_ident }}-well-known-endpoint-compress
{% if matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority | int > 0 %}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.priority={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_priority }}
{% endif %}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.service={{ matrix_static_files_ident }}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.entrypoints={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_entrypoints }}
traefik.http.routers.{{ matrix_static_files_ident }}-well-known-endpoint.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_ident }}-well-known-endpoint.tls.certResolver={{ matrix_static_files_container_labels_well_known_matrix_endpoint_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Related to /.well-known/matrix
#}
{% endif %}
{{ matrix_static_files_container_labels_additional_labels }}

View File

@ -0,0 +1,50 @@
{
"m.homeserver": {
"base_url": "{{ matrix_static_files_file_matrix_client_property_m_homeserver_base_url }}"
}
{% if matrix_static_files_file_matrix_client_property_m_identity_server_base_url %},
"m.identity_server": {
"base_url": "{{ matrix_static_files_file_matrix_client_property_m_identity_server_base_url }}"
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_m_integrations_managers_api_url and matrix_static_files_file_matrix_client_property_m_integrations_managers_ui_url %},
"m.integrations": {
"managers": [
{
"api_url": "{{ matrix_static_files_file_matrix_client_property_m_integrations_managers_api_url }}",
"ui_url": "{{ matrix_static_files_file_matrix_client_property_m_integrations_managers_ui_url }}"
}
]
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_io_element_jitsi_preferred_domain %},
"io.element.jitsi": {
"preferredDomain": {{ matrix_static_files_file_matrix_client_property_io_element_jitsi_preferred_domain|to_json }}
},
"im.vector.riot.jitsi": {
"preferredDomain": {{ matrix_static_files_file_matrix_client_property_io_element_jitsi_preferred_domain|to_json }}
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_org_matrix_msc3575_proxy_url %},
"org.matrix.msc3575.proxy": {
"url": "{{ matrix_static_files_file_matrix_client_property_org_matrix_msc3575_proxy_url }}"
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_m_tile_server_entries_enabled %},
"m.tile_server": {
"map_style_url": "{{ matrix_static_files_file_matrix_client_property_m_tile_server_map_style_url }}"
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_io_element_e2ee_entries_enabled %},
"io.element.e2ee": {
"default": {{ matrix_static_files_file_matrix_client_property_io_element_e2ee_default|to_json }},
"secure_backup_required": {{ matrix_static_files_file_matrix_client_property_io_element_e2ee_secure_backup_required|to_json }},
"secure_backup_setup_methods": {{ matrix_static_files_file_matrix_client_property_io_element_e2ee_secure_backup_setup_methods|to_json }}
}
{% endif %}
{% if matrix_static_files_file_matrix_client_property_io_element_e2ee_entries_enabled %},
"im.vector.riot.e2ee": {
"default": {{ matrix_static_files_file_matrix_client_property_io_element_e2ee_default|to_json }}
}
{% endif %}
}

View File

@ -0,0 +1,3 @@
{
"m.server": "{{ matrix_static_files_file_matrix_server_property_m_server }}"
}

View File

@ -0,0 +1,6 @@
{
"contacts": {{ matrix_static_files_file_matrix_support_property_m_contacts|to_json }}
{% if matrix_static_files_file_matrix_support_property_m_support_page %},
"support_page": {{ matrix_static_files_file_matrix_support_property_m_support_page|to_json }}
{% endif %}
}

View File

@ -0,0 +1,49 @@
#jinja2: lstrip_blocks: "True"
[Unit]
Description=matrix-static-files server
{% for service in matrix_static_files_systemd_required_services_list %}
Requires={{ service }}
After={{ service }}
{% endfor %}
{% for service in matrix_static_files_systemd_wanted_services_list %}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
[Service]
Type=simple
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-static-files 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-static-files 2>/dev/null || true'
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \
--name=matrix-static-files \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--read-only \
--network={{ matrix_static_files_container_network }} \
{% if matrix_static_files_container_http_host_bind_port %}
-p {{ matrix_static_files_container_http_host_bind_port }}:{{ matrix_static_files_environment_variable_server_port }} \
{% endif %}
--env-file={{ matrix_static_files_base_path }}/env \
--label-file={{ matrix_static_files_base_path }}/labels \
--mount type=bind,src={{ matrix_static_files_public_path }},dst=/public,ro \
--mount type=bind,src={{ matrix_static_files_config_path }},dst=/config,ro \
{{ matrix_static_files_container_image }}
{% for network in matrix_static_files_container_additional_networks %}
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-static-files
{% endfor %}
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-static-files
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-static-files 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-static-files 2>/dev/null || true'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-static-files
[Install]
WantedBy=multi-user.target