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.
 
 

80 lines
3.4 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. [Unit]
  3. Description=Synapse server
  4. {% for service in matrix_synapse_systemd_required_services_list %}
  5. Requires={{ service }}
  6. After={{ service }}
  7. {% endfor %}
  8. {% for service in matrix_synapse_systemd_wanted_services_list %}
  9. Wants={{ service }}
  10. {% endfor %}
  11. DefaultDependencies=no
  12. [Service]
  13. Type=simple
  14. Environment="HOME={{ matrix_systemd_unit_home_path }}"
  15. ExecStartPre=-{{ matrix_host_command_docker }} kill matrix-synapse
  16. ExecStartPre=-{{ matrix_host_command_docker }} rm matrix-synapse
  17. {% if matrix_s3_media_store_enabled %}
  18. # Allow for some time before starting, so that media store can mount.
  19. # Mounting can happen later too, but if we start writing,
  20. # we'd write files to the local filesystem and fusermount will complain.
  21. ExecStartPre={{ matrix_host_command_sleep }} 3
  22. {% endif %}
  23. ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-synapse \
  24. --log-driver=none \
  25. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  26. --cap-drop=ALL \
  27. --entrypoint=python \
  28. --read-only \
  29. --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \
  30. --network={{ matrix_docker_network }} \
  31. {% if matrix_synapse_container_client_api_host_bind_port %}
  32. -p {{ matrix_synapse_container_client_api_host_bind_port }}:8008 \
  33. {% endif %}
  34. {% if matrix_synapse_federation_enabled and matrix_synapse_tls_federation_listener_enabled and matrix_synapse_container_federation_api_tls_host_bind_port %}
  35. -p {{ matrix_synapse_container_federation_api_tls_host_bind_port }}:8448 \
  36. {% endif %}
  37. {% if matrix_synapse_federation_enabled and matrix_synapse_container_federation_api_plain_host_bind_port %}
  38. -p {{ matrix_synapse_container_federation_api_plain_host_bind_port }}:8048 \
  39. {% endif %}
  40. {% if matrix_synapse_metrics_enabled and matrix_synapse_container_metrics_api_host_bind_port %}
  41. -p {{ matrix_synapse_container_metrics_api_host_bind_port }}:{{ matrix_synapse_metrics_port }} \
  42. {% endif %}
  43. {% if matrix_synapse_manhole_enabled and matrix_synapse_container_manhole_api_host_bind_port %}
  44. -p {{ matrix_synapse_container_manhole_api_host_bind_port }}:9000 \
  45. {% endif %}
  46. {% for worker in matrix_synapse_workers_enabled_list %}
  47. {% if matrix_synapse_workers_enabled and not matrix_nginx_proxy_enabled|default(False) %}
  48. {# Expose worker ports (by default 18xxx range) on host if not using internal nginx proxy #}
  49. {% if worker.port != 0 %}
  50. -p {{ worker.port }}:{{ worker.port }} \
  51. {% endif %}
  52. {% endif %}
  53. {# Expose worker metrics ports on host if defined #}
  54. {% if worker.metrics_port != 0 %}
  55. -p {{ worker.metrics_port }}:{{ worker.metrics_port }} \
  56. {% endif %}
  57. {% endfor %}
  58. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data,ro \
  59. --mount type=bind,src={{ matrix_synapse_storage_path }},dst=/matrix-media-store-parent,bind-propagation=slave \
  60. {% for volume in matrix_synapse_container_additional_volumes %}
  61. -v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \
  62. {% endfor %}
  63. {% for arg in matrix_synapse_container_extra_arguments %}
  64. {{ arg }} \
  65. {% endfor %}
  66. {{ matrix_synapse_docker_image }} \
  67. -m synapse.app.homeserver -c /data/homeserver.yaml
  68. ExecStop=-{{ matrix_host_command_docker }} kill matrix-synapse
  69. ExecStop=-{{ matrix_host_command_docker }} rm matrix-synapse
  70. ExecReload={{ matrix_host_command_docker }} exec matrix-synapse kill -HUP 1
  71. Restart=always
  72. RestartSec=30
  73. SyslogIdentifier=matrix-synapse
  74. [Install]
  75. WantedBy=multi-user.target