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.
 
 

47 lines
1.9 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. [Unit]
  3. Description=Matrix Postgres server
  4. After=docker.service
  5. Requires=docker.service
  6. DefaultDependencies=no
  7. [Service]
  8. Type=simple
  9. Environment="HOME={{ matrix_systemd_unit_home_path }}"
  10. ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-postgres 2>/dev/null'
  11. ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-postgres 2>/dev/null'
  12. # We need /dev/shm to be larger than the default to allow VACUUM to work.
  13. # See:
  14. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1362
  15. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1268
  16. ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-postgres \
  17. --log-driver=none \
  18. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  19. --cap-drop=ALL \
  20. --read-only \
  21. --tmpfs=/tmp:rw,noexec,nosuid,size=100m \
  22. --tmpfs=/run/postgresql:rw,noexec,nosuid,size=100m \
  23. --shm-size=256m \
  24. --network={{ matrix_docker_network }} \
  25. {% if matrix_postgres_container_postgres_bind_port %}
  26. -p {{ matrix_postgres_container_postgres_bind_port }}:5432 \
  27. {% endif %}
  28. --env-file={{ matrix_postgres_base_path }}/env-postgres-server \
  29. --mount type=bind,src={{ matrix_postgres_data_path }},dst=/var/lib/postgresql/data \
  30. --mount type=bind,src=/etc/passwd,dst=/etc/passwd,ro \
  31. {% for arg in matrix_postgres_container_extra_arguments %}
  32. {{ arg }} \
  33. {% endfor %}
  34. {{ matrix_postgres_docker_image_to_use }} \
  35. postgres {{ matrix_postgres_process_extra_arguments|join(' ') }}
  36. ExecStopPost=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-postgres 2>/dev/null'
  37. ExecStopPost=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-postgres 2>/dev/null'
  38. Restart=always
  39. RestartSec=30
  40. SyslogIdentifier=matrix-postgres
  41. [Install]
  42. WantedBy=multi-user.target