Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

92 rivejä
4.5 KiB

  1. {#
  2. SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  3. SPDX-License-Identifier: AGPL-3.0-or-later
  4. #}
  5. #jinja2: lstrip_blocks: "True"
  6. [Unit]
  7. Description=Synapse server
  8. {% for service in matrix_synapse_systemd_required_services_list %}
  9. Requires={{ service }}
  10. After={{ service }}
  11. {% endfor %}
  12. {% for service in matrix_synapse_systemd_wanted_services_list %}
  13. Wants={{ service }}
  14. {% endfor %}
  15. {% if matrix_synapse_workers_enabled %}
  16. {% for matrix_synapse_worker_details in matrix_synapse_workers_enabled_list %}
  17. Wants={{ matrix_synapse_worker_details.name }}.service
  18. {% endfor %}
  19. {% endif %}
  20. DefaultDependencies=no
  21. [Service]
  22. Type=simple
  23. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  24. 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-synapse 2>/dev/null || true'
  25. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-synapse 2>/dev/null || true'
  26. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
  27. --rm \
  28. --name=matrix-synapse \
  29. --log-driver=none \
  30. --user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }} \
  31. --cap-drop=ALL \
  32. --read-only \
  33. --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \
  34. --network={{ matrix_synapse_container_network }} \
  35. {% if matrix_synapse_container_client_api_host_bind_port %}
  36. -p {{ matrix_synapse_container_client_api_host_bind_port }}:{{ matrix_synapse_container_client_api_port }} \
  37. {% endif %}
  38. {% if matrix_synapse_federation_enabled and matrix_synapse_tls_federation_listener_enabled and matrix_synapse_container_federation_api_tls_host_bind_port %}
  39. -p {{ matrix_synapse_container_federation_api_tls_host_bind_port }}:{{ matrix_synapse_container_federation_api_tls_port }} \
  40. {% endif %}
  41. {% if matrix_synapse_federation_enabled and matrix_synapse_federation_port_enabled and matrix_synapse_container_federation_api_plain_host_bind_port %}
  42. -p {{ matrix_synapse_container_federation_api_plain_host_bind_port }}:{{ matrix_synapse_container_federation_api_plain_port }} \
  43. {% endif %}
  44. {% if matrix_synapse_metrics_enabled and matrix_synapse_container_metrics_api_host_bind_port %}
  45. -p {{ matrix_synapse_container_metrics_api_host_bind_port }}:{{ matrix_synapse_metrics_port }} \
  46. {% endif %}
  47. {% if matrix_synapse_manhole_enabled and matrix_synapse_container_manhole_api_host_bind_port %}
  48. -p {{ matrix_synapse_container_manhole_api_host_bind_port }}:9000 \
  49. {% endif %}
  50. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data,ro \
  51. --mount type=bind,src={{ matrix_synapse_storage_path }},dst=/matrix-media-store-parent,bind-propagation=slave \
  52. --label-file={{ matrix_synapse_base_path }}/labels \
  53. {% for volume in matrix_synapse_container_additional_volumes %}
  54. --mount type={{ volume.type | default('bind' if '/' in volume.src else 'volume') }},src={{ volume.src }},dst={{ volume.dst }}{{ (',' + volume.options) if volume.options else '' }} \
  55. {% endfor %}
  56. {% for arg in matrix_synapse_container_arguments %}
  57. {{ arg }} \
  58. {% endfor %}
  59. {% for arg in matrix_synapse_container_master_extra_arguments %}
  60. {{ arg }} \
  61. {% endfor %}
  62. {{ matrix_synapse_docker_image_final }} \
  63. run -m synapse.app.homeserver -c /data/homeserver.yaml
  64. {% for network in matrix_synapse_container_additional_networks %}
  65. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-synapse
  66. {% endfor %}
  67. ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-synapse
  68. {% if matrix_synapse_systemd_service_post_start_delay_seconds > 0 %}
  69. ExecStartPost=-{{ matrix_host_command_sleep }} {{ matrix_synapse_systemd_service_post_start_delay_seconds }}
  70. {% endif %}
  71. 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-synapse 2>/dev/null || true'
  72. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-synapse 2>/dev/null || true'
  73. ExecReload={{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse /bin/sh -c 'kill -HUP 1'
  74. Restart=always
  75. RestartSec=30
  76. SyslogIdentifier=matrix-synapse
  77. [Install]
  78. WantedBy=multi-user.target