Просмотр исходного кода

Merge pull request #9759 from weseek/imprv/163435-163436-make-pdf-converter-devcontainer-creation-optional

make pdf-converter devcontainer creation optional
Yuki Takei 1 год назад
Родитель
Сommit
43f06ac9f5

+ 2 - 1
.devcontainer/app/devcontainer.json

@@ -2,7 +2,7 @@
 // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
 {
   "name": "GROWI-Dev",
-  "dockerComposeFile": "../compose.yml",
+  "dockerComposeFile": ["../compose.yml", "../compose.extend.yml"],
   "service": "app",
   "workspaceFolder": "/workspace/growi",
 
@@ -15,6 +15,7 @@
   // Use 'forwardPorts' to make a list of ports inside the container available locally.
   // "forwardPorts": [],
 
+  "initializeCommand": "/bin/bash .devcontainer/pdf-converter/initializeCommand.sh",
   // Use 'postCreateCommand' to run commands after the container is created.
   "postCreateCommand": "/bin/bash ./.devcontainer/app/postCreateCommand.sh",
 

+ 4 - 0
.devcontainer/app/initializeCommand.sh

@@ -0,0 +1,4 @@
+# prevent file not found error on docker compose up
+if [ ! -f ".devcontainer/compose.extend.yml" ]; then
+  touch .devcontainer/compose.extend.yml
+fi

+ 12 - 0
.devcontainer/compose.extend.template.yml

@@ -0,0 +1,12 @@
+# A template of the file for extending the primary docker compose configuration.
+# To actually use this file, create a `compose.override.yml` file and copy the contents of this file into it.
+services:
+  pdf-converter:
+    # enabling devcontainer 'features' was not working for secondary devcontainer (https://github.com/devcontainers/features/issues/1175)
+    image: mcr.microsoft.com/vscode/devcontainers/javascript-node:1-20
+    volumes:
+      - ..:/workspace/growi:delegated
+      - pnpm-store:/workspace/growi/.pnpm-store
+      - node_modules:/workspace/growi/node_modules
+      - page_bulk_export_tmp:/tmp/page-bulk-export
+    tty: true

+ 0 - 10
.devcontainer/compose.yml

@@ -45,16 +45,6 @@ services:
       - /usr/share/elasticsearch/data
       - ../../growi-docker-compose/elasticsearch/v8/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
 
-  pdf-converter:
-    # enabling devcontainer 'features' was not working for secondary devcontainer (https://github.com/devcontainers/features/issues/1175)
-    image: mcr.microsoft.com/vscode/devcontainers/javascript-node:1-20
-    volumes:
-      - ..:/workspace/growi:delegated
-      - pnpm-store:/workspace/growi/.pnpm-store
-      - node_modules:/workspace/growi/node_modules
-      - page_bulk_export_tmp:/tmp/page-bulk-export
-    tty: true
-
 volumes:
   pnpm-store:
   node_modules:

+ 2 - 1
.devcontainer/pdf-converter/devcontainer.json

@@ -1,12 +1,13 @@
 {
   "name": "GROWI-PDF-Converter",
-  "dockerComposeFile": "../compose.yml",
+  "dockerComposeFile": ["../compose.yml", "../compose.extend.yml"],
   "service": "pdf-converter",
   "workspaceFolder": "/workspace/growi",
 
   // Use 'forwardPorts' to make a list of ports inside the container available locally.
   // "forwardPorts": [],
 
+  "initializeCommand": "/bin/bash .devcontainer/pdf-converter/initializeCommand.sh",
   // Use 'postCreateCommand' to run commands after the container is created.
   "postCreateCommand": "/bin/bash ./.devcontainer/pdf-converter/postCreateCommand.sh",
 

+ 4 - 0
.devcontainer/pdf-converter/initializeCommand.sh

@@ -0,0 +1,4 @@
+# prevent file not found error on docker compose up
+if [ ! -f ".devcontainer/compose.extend.yml" ]; then
+  touch .devcontainer/compose.extend.yml
+fi

+ 2 - 0
.gitignore

@@ -44,3 +44,5 @@ yarn-error.log*
 
 # pnpm deploy target dir
 out
+
+.devcontainer/compose.extend.yml

+ 0 - 1
apps/app/.env.development

@@ -15,7 +15,6 @@ ELASTICSEARCH_REQUEST_TIMEOUT=15000
 ELASTICSEARCH_REJECT_UNAUTHORIZED=true
 OGP_URI="http://ogp:8088"
 QUESTIONNAIRE_SERVER_ORIGIN="http://host.docker.internal:3003"
-BULK_EXPORT_PDF_CONVERTER_URI=http://pdf-converter:3010
 # DRAWIO_URI="http://localhost:8080/?offline=1&https=0"
 # S2SMSG_PUBSUB_SERVER_TYPE=nchan
 # PUBLISH_OPEN_API=true

+ 4 - 2
apps/pdf-converter/README.md

@@ -10,6 +10,7 @@ This app (PDF-Converter) is necessary to convert markdown pages to PDF during th
 
 ## Developing inside a devcontainer
 1. Open VSCode
+1. Create `.devcontainer/compose.extend.yml` with the same contents as `.devcontainer/compose.extend.template.yml`
 1. Open command palette (Windows: Ctrl + Shift + P, Mac: Cmd + Shift + P)
 1. Choose `Dev Containers: Open folder in Container...`
 1. Choose the root growi directory you have cloned from https://github.com/weseek/growi
@@ -21,6 +22,7 @@ This app (PDF-Converter) is necessary to convert markdown pages to PDF during th
 ## Requesting PDF-Converter from GROWI (both running in a devcontainer)
 1. Open VSCode and open GROWI devcontainer
     - Choose `GROWI-Dev` for the container to open
+1. Add `BULK_EXPORT_PDF_CONVERTER_URI=http://pdf-converter:3010` to `apps/app/.env.development.local`
 1. Open a new VSCode window and open PDF-Converter devcontainer
     - Follow [Developing inside a devcontainer](#developing-inside-a-devcontainer)
 1. Start both apps
@@ -28,7 +30,7 @@ This app (PDF-Converter) is necessary to convert markdown pages to PDF during th
     - It might take a few minutes, depending on GROWI's configurations
 
 ### Note
-When creating both containers from scratch or rebuilding them, **make sure to select and create GROWI-Dev first**.  
+When creating both containers from scratch or rebuilding them, **make sure to select and create GROWI-Dev first**.
 This is necessary because GROWI-Dev uses devcontainer features for enabling node, and [features is only enabled for the first container created](https://github.com/devcontainers/spec/issues/546).
 
 ## PDF-Converter client library
@@ -39,4 +41,4 @@ When you update the PDF-Converter API, you should also always update the client
 You can update the client library by one of the following ways:
 - Execute `cd ${growi_root_path}/packages/pdf-converter-client && pnpm gen:client-code`
 - Start GROWI app
-    - Inside GROWI devcontainer (not PDF-Converter devcontainer), execute `cd ${growi_root_path}/apps/app && turbo dev`
+    - Inside GROWI devcontainer (not PDF-Converter devcontainer), execute `cd ${growi_root_path}/apps/app && turbo dev`

+ 3 - 1
apps/pdf-converter/README_JP.md

@@ -10,6 +10,7 @@ GROWI には、ページを PDF 形式で一括エクスポートする機能が
 
 ## Devcontainer 内での開発
 1. VSCode を開く
+1. `.devcontainer/compose.extend.template.yml` と同様の内容で `.devcontainer/compose.extend.yml` を作成
 1. コマンドパレットを開く(Windows: `Ctrl + Shift + P`、Mac: `Cmd + Shift + P`)
 1. `Dev Containers: Open folder in Container...` を選択
 1. [https://github.com/weseek/growi](https://github.com/weseek/growi) からクローンした GROWI のルートディレクトリを選択
@@ -21,6 +22,7 @@ GROWI には、ページを PDF 形式で一括エクスポートする機能が
 ## GROWI から PDF-Converter へのリクエストを実行(両方とも devcontainer 内で起動)
 1. VSCode を開き、GROWI の devcontainer を開く
    - `GROWI-Dev` をコンテナとして選択
+1. `apps/app/.env.development.local` に `BULK_EXPORT_PDF_CONVERTER_URI=http://pdf-converter:3010` を追記
 1. 新しい VSCode ウィンドウを開き、PDF-Converter の devcontainer を開く
    - [Devcontainer 内での開発](#devcontainer-内での開発) の手順に従う
 1. 両方のアプリを起動
@@ -28,7 +30,7 @@ GROWI には、ページを PDF 形式で一括エクスポートする機能が
    - GROWI の設定によっては、処理に数分かかる場合があります
 
 ### 備考
-二つのコンテナを初めて作成する時や、コンテナを rebuild する時、**必ず GROWI-Dev を先に選択して作成してください**。  
+二つのコンテナを初めて作成する時や、コンテナを rebuild する時、**必ず GROWI-Dev を先に選択して作成してください**。
 GROWI-Dev は devcontainer features を使用して node を有効化していますが、[features は最初に作成したコンテナにしか有効になりません](https://github.com/devcontainers/spec/issues/546)。
 
 ## PDF-Converter クライアントライブラリ