azurite.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.mzcompose.service import Service, ServiceHealthcheck
  10. def azure_blob_uri(address: str = "azurite") -> str:
  11. return f"http://devstoreaccount1.{address}:10000/container"
  12. class Azurite(Service):
  13. def __init__(
  14. self,
  15. name: str = "azurite",
  16. aliases: list[str] = ["azurite", "devstoreaccount1.azurite"],
  17. command: list[str] | None = None,
  18. in_memory: bool = False,
  19. healthcheck: ServiceHealthcheck | None = None,
  20. stop_grace_period: str = "120s",
  21. ports: list[int | str] = [10000],
  22. allow_host_ports: bool = False,
  23. ):
  24. if command is None:
  25. command = [
  26. "azurite-blob",
  27. "--blobHost",
  28. "0.0.0.0",
  29. "--blobPort",
  30. "10000",
  31. "--disableProductStyleUrl",
  32. "--loose",
  33. ]
  34. if in_memory:
  35. command.append("--inMemoryPersistence")
  36. if healthcheck is None:
  37. healthcheck = {
  38. "test": "nc 127.0.0.1 10000 -z",
  39. "interval": "1s",
  40. "start_period": "30s",
  41. }
  42. super().__init__(
  43. name=name,
  44. config={
  45. "mzbuild": "azurite",
  46. "networks": {"default": {"aliases": aliases}},
  47. "ports": ports,
  48. "allow_host_ports": allow_host_ports,
  49. "command": command,
  50. "init": True,
  51. "healthcheck": healthcheck,
  52. "stop_grace_period": stop_grace_period,
  53. },
  54. )