docker-compose.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. {% set tpl = ix_lib.base.render.Render(values) %}
  2. {# Validate early #}
  3. {% if values.storage.data_dirs|length == 0 %}
  4. {% do tpl.funcs.fail("At least 1 storage item must be set") %}
  5. {% endif %}
  6. {% if values.storage.data_dirs|length > 1 %}
  7. {% if not values.minio.multi_mode.enabled and values.minio.multi_mode.entries|length == 0 %}
  8. {% do tpl.funcs.fail("[Multi Mode] must be enabled and entries must be set if more than 1 storage item is set") %}
  9. {% endif %}
  10. {% endif %}
  11. {% set mount_paths = namespace(x=[]) %}
  12. {% for store in values.storage.data_dirs %}
  13. {% do mount_paths.x.append(store.mount_path.rstrip("/")) %}
  14. {% endfor %}
  15. {% if mount_paths.x|unique|list|length != mount_paths.x|length %}
  16. {% do tpl.funcs.fail("Mount paths in storage items must be unique, found duplicates: [%s]"|format(mount_paths.x|join(", "))) %}
  17. {% endif %}
  18. {% if values.minio.multi_mode.entries|length > 0 %}
  19. {% set disallowed_keys = ["server"] %}
  20. {% for item in values.minio.multi_mode.entries %}
  21. {% if item in disallowed_keys %}
  22. {% do tpl.funcs.fail("MinIO: Value [%s] is not allowed in [Multi Mode] items"|format(item)) %}
  23. {% endif %}
  24. {# /data{1..2} should fail but /data{1...2} should pass #}
  25. {% if item.startswith("/") and ('{' in item or '}' in item) and "..." not in item %}
  26. {% do tpl.funcs.fail("MinIO: [Multi Mode] item [%s] must have 3 dots when they are paths with expansion eg [/some_path{1...4}]"|format(item)) %}
  27. {% endif %}
  28. {% endfor %}
  29. {% endif %}
  30. {# Validation complete #}
  31. {% set proto = "https" if values.network.certificate_id else "http" %}
  32. {% set c1 = tpl.add_container(values.consts.minio_container_name, "image") %}
  33. {% set perm_container = tpl.deps.perms(values.consts.perms_container_name) %}
  34. {% set perm_config = {"uid":values.run_as.user, "gid": values.run_as.group, "mode": "check"} %}
  35. {% do c1.set_user(values.run_as.user, values.run_as.group) %}
  36. {% do c1.healthcheck.set_custom_test("mc ready --insecure --cluster-read health") %}
  37. {% set cmd = namespace(x=[
  38. "server",
  39. "--address", ":%d"|format(values.network.api_port.port_number),
  40. "--console-address", ":%d"|format(values.network.console_port.port_number),
  41. ]) %}
  42. {% if values.network.certificate_id %}
  43. {% do cmd.x.extend(["--certs-dir", "/.minio/certs"]) %}
  44. {% set cert = values.ix_certificates[values.network.certificate_id] %}
  45. {% do c1.configs.add("private", cert.privatekey, "/.minio/certs/private.key") %}
  46. {% do c1.configs.add("public", cert.certificate, "/.minio/certs/public.crt") %}
  47. {% endif %}
  48. {% if values.minio.logging.quiet %}
  49. {% do cmd.x.append("--quiet") %}
  50. {% endif %}
  51. {% if values.minio.logging.anonymous %}
  52. {% do cmd.x.append("--anonymous") %}
  53. {% endif %}
  54. {% do c1.set_command(cmd.x) %}
  55. {# Stores minio "volumes" that will be passed in the MINIO_VOLUMES env var #}
  56. {% set minio_config_items = namespace(x=[]) %}
  57. {% for store in values.storage.data_dirs %}
  58. {% do c1.add_storage(store.mount_path, store) %}
  59. {% do perm_container.add_or_skip_action(store.mount_path, store, perm_config) %}
  60. {% do minio_config_items.x.append(store.mount_path) %}
  61. {% endfor %}
  62. {% do c1.environment.add_user_envs(values.minio.additional_envs) %}
  63. {% do c1.environment.add_env("MC_HOST_health", "%s://localhost:%d" | format(proto, values.network.api_port.port_number)) %}
  64. {% do c1.environment.add_env("MINIO_ROOT_USER", values.minio.credentials.access_key) %}
  65. {% do c1.environment.add_env("MINIO_ROOT_PASSWORD", values.minio.credentials.secret_key) %}
  66. {% if values.network.server_url %}
  67. {% do c1.environment.add_env("MINIO_SERVER_URL", values.network.server_url) %}
  68. {% endif %}
  69. {% if values.network.console_url %}
  70. {% do c1.environment.add_env("MINIO_BROWSER_REDIRECT_URL", values.network.console_url) %}
  71. {% endif %}
  72. {% if values.minio.multi_mode.entries %}
  73. {% do c1.environment.add_env("MINIO_VOLUMES", values.minio.multi_mode.entries|join(" ")) %}
  74. {% else %}
  75. {% do c1.environment.add_env("MINIO_VOLUMES", minio_config_items.x|join(" ")) %}
  76. {% endif %}
  77. {% do c1.add_port(values.network.console_port) %}
  78. {% do c1.add_port(values.network.api_port) %}
  79. {% if perm_container.has_actions() %}
  80. {% do perm_container.activate() %}
  81. {% do c1.depends.add_dependency(values.consts.perms_container_name, "service_completed_successfully") %}
  82. {% endif %}
  83. {% do tpl.portals.add(values.network.console_port, {"scheme": proto}) %}
  84. {{ tpl.render() | tojson }}