docker-compose.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {% from "macros/setup.sh" import setup %}
  2. {% set tpl = ix_lib.base.render.Render(values) %}
  3. {% set c1 = tpl.add_container(values.consts.transmission_container_name, "image") %}
  4. {% do c1.set_user(0, 0) %}
  5. {% do c1.add_caps(["CHOWN", "FOWNER", "DAC_OVERRIDE", "SETGID", "SETUID"]) %}
  6. {% do c1.healthcheck.set_test("netcat", {"port": values.network.web_port.port_number}) %}
  7. {% set config = namespace(x={
  8. "rpc-enabled": true,
  9. "rpc-bind-address": "0.0.0.0",
  10. "rpc-port": values.network.web_port.port_number,
  11. "peer-port": values.network.peer_port.port_number,
  12. "download-dir": values.storage.downloads_complete.mount_path,
  13. "incomplete-dir-enabled": values.storage.enable_incomplete_dir,
  14. }) %}
  15. {% if values.storage.enable_incomplete_dir %}
  16. {% if (not values.storage.mount_incomplete_as_separate_storage) and (not values.storage.incomplete_dir_path.startswith(values.storage.downloads_complete.mount_path)) %}
  17. {% do tpl.funcs.fail("Incomplete Directory Path [%s] must be inside Downloads Complete Path [%s], when 'Mount Incomplete Directory as Separate Storage' is disabled." | format(values.storage.incomplete_dir_path, values.storage.downloads_complete.mount_path)) %}
  18. {% endif %}
  19. {% do config.x.update({"incomplete-dir": values.storage.incomplete_dir_path}) %}
  20. {% endif %}
  21. {% for item in values.transmission.additional_config %}
  22. {% if item.key in values.consts.reserved_keys %}
  23. {% do tpl.funcs.fail("Reserved key [%s] cannot be used in additional_config. Use the corresponding field" | format(item.key)) %}
  24. {% endif %}
  25. {% do config.x.update({item.key: tpl.funcs.auto_cast(item.value)}) %}
  26. {% endfor %}
  27. {% do c1.configs.add("setup.sh", setup(tpl, config.x), "/custom-cont-init.d/setup.sh", "0755") %}
  28. {% do c1.add_port(values.network.web_port) %}
  29. {% do c1.add_port(values.network.peer_port) %}
  30. {% do c1.add_port(values.network.peer_port, {"protocol": "udp"}) %}
  31. {% do c1.environment.add_user_envs(values.transmission.additional_envs) %}
  32. {% do c1.add_storage("/config", values.storage.config) %}
  33. {% do c1.add_storage(values.storage.downloads_complete.mount_path, values.storage.downloads_complete) %}
  34. {% if values.storage.enable_incomplete_dir and values.storage.mount_incomplete_as_separate_storage %}
  35. {% do c1.add_storage(values.storage.incomplete_dir_path, values.storage.downloads_incomplete) %}
  36. {% endif %}
  37. {% for store in values.storage.additional_storage %}
  38. {% do c1.add_storage(store.mount_path, store) %}
  39. {% endfor %}
  40. {% do tpl.portals.add(values.network.web_port, {"path": "/transmission/web"}) %}
  41. {% do tpl.notes.set_body(values.consts.notes_body) %}
  42. {{ tpl.render() | tojson }}