compose.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. services:
  2. app:
  3. image: mcr.microsoft.com/devcontainers/base:ubuntu
  4. volumes:
  5. - ..:/workspace/growi:delegated
  6. - pnpm-store:/workspace/.pnpm-store
  7. - ${HOME}/.claude:/home/vscode/.claude
  8. - ${HOME}/.config/gh:/home/vscode/.config/gh
  9. - ${HOME}/.config/glab-cli:/home/vscode/.config/glab-cli
  10. - ../../growi-docker-compose:/workspace/growi-docker-compose:delegated
  11. - ../../share:/workspace/share:delegated
  12. - page_bulk_export_tmp:/tmp/page-bulk-export
  13. tty: true
  14. networks:
  15. - default
  16. - opentelemetry-collector-dev-setup_default
  17. mongo:
  18. image: mongo:8.2
  19. restart: unless-stopped
  20. command: ["--replSet", "rs0", "--bind_ip_all"]
  21. ports:
  22. - 27017
  23. volumes:
  24. - /data/db
  25. healthcheck:
  26. test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
  27. interval: 5s
  28. timeout: 5s
  29. retries: 20
  30. # Initializes the replica set and ensures Feature Compatibility Version matches the mongo image.
  31. # The replica set (single node `rs0`) is required for transactions and change streams used in development.
  32. # FCV update is required when the mongo image is upgraded while existing data persists in the volume.
  33. # https://www.mongodb.com/ja-jp/docs/upcoming/release-notes/8.2-upgrade-standalone/
  34. mongo-init:
  35. image: mongo:8.2
  36. depends_on:
  37. mongo:
  38. condition: service_healthy
  39. restart: 'no'
  40. entrypoint:
  41. - mongosh
  42. - --quiet
  43. - --host
  44. - mongo:27017
  45. - --eval
  46. - |
  47. // 1. Initiate the replica set (single node) if not already initialized.
  48. try {
  49. const status = rs.status();
  50. print(`Replica set already initialized: $${status.set}`);
  51. } catch (e) {
  52. if (e.codeName === 'NotYetInitialized') {
  53. print('Initiating replica set rs0...');
  54. rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'mongo:27017' }] });
  55. // Wait until this node is elected primary so subsequent admin commands succeed.
  56. while (!db.hello().isWritablePrimary) {
  57. sleep(500);
  58. }
  59. print('Replica set initiated and primary is ready');
  60. } else {
  61. throw e;
  62. }
  63. }
  64. // 2. Ensure FCV matches the mongo image.
  65. const target = '8.2';
  66. const result = db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 });
  67. if (result.featureCompatibilityVersion.version === target) {
  68. print(`FCV already $${target}`);
  69. } else {
  70. db.adminCommand({ setFeatureCompatibilityVersion: target, confirm: true });
  71. print(`FCV upgraded: $${result.featureCompatibilityVersion.version} -> $${target}`);
  72. }
  73. # This container requires '../../growi-docker-compose' repository
  74. # cloned from https://github.com/growilabs/growi-docker-compose.git
  75. elasticsearch:
  76. image: docker.elastic.co/elasticsearch/elasticsearch:9.3.3
  77. restart: unless-stopped
  78. ports:
  79. - 9200
  80. environment:
  81. - bootstrap.memory_lock=true
  82. - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
  83. - LOG4J_FORMAT_MSG_NO_LOOKUPS=true # CVE-2021-44228 mitigation for Elasticsearch <= 6.8.20/7.16.0
  84. ulimits:
  85. memlock:
  86. soft: -1
  87. hard: -1
  88. volumes:
  89. - /usr/share/elasticsearch/data
  90. - ../../growi-docker-compose/elasticsearch/v9/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  91. - ../../growi-docker-compose/elasticsearch/v9/config/elasticsearch-plugins.yml:/usr/share/elasticsearch/config/elasticsearch-plugins.yml
  92. volumes:
  93. pnpm-store:
  94. page_bulk_export_tmp:
  95. networks:
  96. default:
  97. opentelemetry-collector-dev-setup_default:
  98. external: ${OPENTELEMETRY_COLLECTOR_DEV_ENABLED:-false}