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.
 
 

67 lines
3.3 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. [Unit]
  3. Description=Matrix Coturn server
  4. {% for service in matrix_coturn_systemd_required_services_list %}
  5. Requires={{ service }}
  6. After={{ service }}
  7. {% endfor %}
  8. DefaultDependencies=no
  9. [Service]
  10. Type=simple
  11. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  12. 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-coturn 2>/dev/null || true'
  13. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-coturn 2>/dev/null || true'
  14. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
  15. --rm \
  16. --name=matrix-coturn \
  17. --log-driver=none \
  18. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  19. --cap-drop=ALL \
  20. --cap-add=NET_BIND_SERVICE \
  21. --entrypoint=turnserver \
  22. --read-only \
  23. --tmpfs=/var/tmp:rw,noexec,nosuid,size=100m \
  24. --network={{ matrix_coturn_container_network }} \
  25. {% if matrix_coturn_container_stun_plain_host_bind_port != '' %}
  26. -p {{ matrix_coturn_container_stun_plain_host_bind_port }}:3478 \
  27. -p {{ matrix_coturn_container_stun_plain_host_bind_port }}:3478/udp \
  28. {% endif %}
  29. {% if matrix_coturn_container_stun_tls_host_bind_port != '' %}
  30. -p {{ matrix_coturn_container_stun_tls_host_bind_port }}:5349 \
  31. -p {{ matrix_coturn_container_stun_tls_host_bind_port }}:5349/udp \
  32. {% endif %}
  33. {% if matrix_coturn_container_turn_range_listen_interface is not in [none, 'none'] %}
  34. -p {{ matrix_coturn_container_turn_range_listen_interface }}{{ ':' if matrix_coturn_container_turn_range_listen_interface else '' }}{{ matrix_coturn_turn_udp_min_port }}-{{ matrix_coturn_turn_udp_max_port }}:{{ matrix_coturn_turn_udp_min_port }}-{{ matrix_coturn_turn_udp_max_port }}/udp \
  35. {% endif %}
  36. --mount type=bind,src={{ matrix_coturn_config_path }},dst=/turnserver.conf,ro \
  37. {% for volume in matrix_coturn_container_additional_volumes %}
  38. --mount type={{ volume.type | default('bind' if '/' in volume.src else 'volume') }},src={{ volume.src }},dst={{ volume.dst }}{{ (',' + volume.options) if volume.options else '' }} \
  39. {% endfor %}
  40. {% for arg in matrix_coturn_container_extra_arguments %}
  41. {{ arg }} \
  42. {% endfor %}
  43. {{ matrix_coturn_docker_image }} \
  44. -c /turnserver.conf
  45. {% for network in matrix_coturn_container_additional_networks %}
  46. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-coturn
  47. {% endfor %}
  48. ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-coturn
  49. 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-coturn 2>/dev/null || true'
  50. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-coturn 2>/dev/null || true'
  51. # This only reloads certificates (not other configuration).
  52. # See: https://github.com/coturn/coturn/pull/236
  53. ExecReload={{ devture_systemd_docker_base_host_command_docker }} exec matrix-coturn kill -USR2 1
  54. Restart=always
  55. RestartSec=30
  56. SyslogIdentifier=matrix-coturn
  57. [Install]
  58. WantedBy=multi-user.target