docker-compose.yaml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. {% set tpl = ix_lib.base.render.Render(values) %}
  2. {% set c1 = tpl.add_container(values.consts.zerotier_container_name, "image") %}
  3. {% do c1.add_caps(["NET_ADMIN", "NET_RAW", "AUDIT_WRITE", "CHOWN", "DAC_OVERRIDE", "FOWNER", "NET_BIND_SERVICE", "SETGID", "SETUID", "SETPCAP", "SYS_ADMIN"]) %}
  4. {% do c1.healthcheck.set_custom_test("/healthcheck.sh") %}
  5. {% set cmd = namespace(x=[]) %}
  6. {% for net in values.zerotier.networks %}
  7. {% do cmd.x.append(net|lower) %}
  8. {% else %}
  9. {% do tpl.funcs.fail("Zerotier requires at least one network to be configured") %}
  10. {% endfor %}
  11. {% do c1.set_command(cmd.x) %}
  12. {% if not values.network.host_network %}
  13. {% do c1.sysctls.add("net.ipv4.ip_forward", 1) %}
  14. {% do c1.sysctls.add("net.ipv6.conf.all.forwarding", 1) %}
  15. {% endif %}
  16. {% if values.zerotier.auth_token %}
  17. {% do c1.environment.add_env("ZEROTIER_API_TOKEN", values.zerotier.auth_token) %}
  18. {% endif %}
  19. {% if values.zerotier.identity_public %}
  20. {% do c1.environment.add_env("ZEROTIER_IDENTITY_PUBLIC", values.zerotier.identity_public) %}
  21. {% endif %}
  22. {% if values.zerotier.identity_secret %}
  23. {% do c1.environment.add_env("ZEROTIER_IDENTITY_SECRET", values.zerotier.identity_secret) %}
  24. {% endif %}
  25. {% do c1.environment.add_user_envs(values.zerotier.additional_envs) %}
  26. {% do c1.add_tun_device() %}
  27. {% do c1.add_storage("/var/lib/zerotier-one", values.storage.config) %}
  28. {% for store in values.storage.additional_storage %}
  29. {% do c1.add_storage(store.mount_path, store) %}
  30. {% endfor %}
  31. {{ tpl.render() | tojson }}