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.
 
 
 

60 lines
2.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=Matrix baibot bot
  8. {% for service in matrix_bot_baibot_systemd_required_services_list %}
  9. Requires={{ service }}
  10. After={{ service }}
  11. {% endfor %}
  12. {% for service in matrix_bot_baibot_systemd_wanted_services_list %}
  13. Wants={{ service }}
  14. {% endfor %}
  15. DefaultDependencies=no
  16. [Service]
  17. Type=simple
  18. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  19. 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-bot-baibot 2>/dev/null || true'
  20. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-baibot 2>/dev/null || true'
  21. {#
  22. We mount a tmpfs at /tmp, because the bot may write temporary files there
  23. (see its `src/agent/provider/openai_compat/controller.rs`).
  24. #}
  25. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
  26. --rm \
  27. --name=matrix-bot-baibot \
  28. --log-driver=none \
  29. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  30. --cap-drop=ALL \
  31. --read-only \
  32. --network={{ matrix_bot_baibot_container_network }} \
  33. --env-file={{ matrix_bot_baibot_config_path }}/env \
  34. --mount type=bind,src={{ matrix_bot_baibot_config_path }}/config.yml,dst=/app/config.yml,ro \
  35. --mount type=bind,src={{ matrix_bot_baibot_data_path }},dst=/data \
  36. --tmpfs=/tmp:rw,noexec,nosuid,size=1024m \
  37. {% for arg in matrix_bot_baibot_container_extra_arguments %}
  38. {{ arg }} \
  39. {% endfor %}
  40. {{ matrix_bot_baibot_container_image }}
  41. {% for network in matrix_bot_baibot_container_additional_networks %}
  42. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-bot-baibot
  43. {% endfor %}
  44. ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-bot-baibot
  45. 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-bot-baibot 2>/dev/null || true'
  46. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-baibot 2>/dev/null || true'
  47. Restart=always
  48. RestartSec=30
  49. SyslogIdentifier=matrix-bot-baibot
  50. [Install]
  51. WantedBy=multi-user.target