Skip to content

feat: support renderMode: docker without Docker Desktop#792

Open
u1f992 wants to merge 22 commits into
mainfrom
test/render-mode-docker-coverage
Open

feat: support renderMode: docker without Docker Desktop#792
u1f992 wants to merge 22 commits into
mainfrom
test/render-mode-docker-coverage

Conversation

@u1f992
Copy link
Copy Markdown
Member

@u1f992 u1f992 commented May 9, 2026

Dockerにパスが通っている状態は、Win/Mac/Linux各プラットフォームでDocker Engineのみを使用する場合/Docker Desktopを利用する場合の計6パターンが考えられます(メモ)。Docker Desktopの商用利用には制限があるため、Docker Engineだけを利用したいケースが現実的に存在します。

現在のrenderMode: dockerの実装はDocker Desktopが自動で付与する--add-host host.docker.internal=host-gatewayを暗黙に想定しており、Docker Engineを単体で利用するケースで正しく動作しません(特にLinux。MacではColimaが自動で付与するようです)。

https://github.com/docker/docs/blob/ffb61075c112b7944612dd9e511e510029c7348e/data/cli/engine/docker_container_run.yaml#L2265-L2269 (latest)

WindowsではWSL内に通常のLinuxの手順に従ってDocker Engineをインストールし、名前付きパイプでWindows側CLIと通信することになりますが、この場合Docker Engineの実体はあくまでLinux側にあるため、マウントパスはWSL内部のパス(/mnt/ ...経由でWindows側にアクセス)しか正しく処理することができません。現在のVivliostyle CLIではupathで処理した絶対パスを渡しており、パス変換処理を差し込めるようにする必要があります。

WSLかつデフォルトのNATモードネットワークを使用している場合はhost-gatewayが指すのはWSL VM内になり、Windows側で起動するPlaywrightからアクセスできません。host-gatewayの代わりに、WSLが動的に決めるWindowsとのゲートウェイを指定できるようにする必要があります。一方でMirroredモードの場合は--add-host host.docker.internal=127.0.0.1に加えて--network=hostが必要です。

このPRでは、renderMode: { mode: "docker"; hostGateway?: string; pathTransformer?: (string) => string; extraRunArgs?: string[] }に拡張子し、現在判明している限りで特定ケースに偏らない一般的な形で、Dockerに関する挙動を調整できるようにします。典型的な設定下で使用するプリセットとヘルパー関数も提供します。特定の環境変数で有効化するテストケースを追加しています。

Linux(Docker Engineのみ)・Windows(WSLにDocker Engine・Docker Desktop)・macOS(ColimaにDocker Engine・Docker Desktop)の5パターンでテスト済みです。

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Vivliostyle CLI’s renderMode: docker support to work in environments that don’t provide Docker Desktop’s implicit host.docker.internal behavior, and adds WSL-specific helpers to support “Windows Node.js + dockerd in WSL” hybrid setups.

Changes:

  • Extend renderMode to accept object forms for docker/local and normalize them during config resolution.
  • Update container invocation to always provide host.docker.internal via --add-host ...:host-gateway, with optional overrides (hostGateway, pathTransformer, extraRunArgs).
  • Add WSL utilities (getWslHostIp, wslPathTransformer, NAT/mirrored presets) and comprehensive unit/integration tests.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/wsl.test.ts Unit tests for WSL helper utilities and presets.
tests/render-on-docker.test.ts Opt-in integration tests for docker rendering, including WSL hybrid scenarios.
tests/fixtures/render-on-docker/manuscript.md Fixture manuscript for docker rendering tests.
tests/container.test.ts Unit tests asserting docker CLI args generation (host gateway, path transform, extra args).
tests/snapshots/config.test.ts.snap Snapshot updates reflecting normalized renderMode object shape.
src/wsl.ts New WSL helper module (gateway discovery + path translation + presets).
src/index.ts Export WSL helpers from the public entrypoint.
src/core/build.ts Switch docker-render decision to target.renderMode.mode.
src/container.ts Add --add-host, hostGateway/extraRunArgs plumbing, and bind-mount path transformer support.
src/config/schema.ts Extend RenderMode schema to include object forms and docker-specific fields.
src/config/resolve.ts Normalize renderMode to a resolved object form and update docker-mode checks accordingly.
docs/config.md Update documented renderMode type to include the new object forms/fields.
docs/api-javascript.md API docs updates for new exports and updated renderMode typing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/config.md Outdated
Comment thread src/config/resolve.ts
Comment thread src/config/schema.ts
Comment thread tests/container.test.ts Outdated
const enableAnyHybrid = enableHybridNat || enableHybridMirrored;
const itBasic = enableAnyHybrid ? it.fails : it;

describe.skipIf(!image)(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

render-on-docker.test.ts のテストは、現状ではGitHub Actions上での確認がスキップされていますが、テストが確実に実行されるためにActions上での実行もサポートすることが望ましいです。Win + WSL上で動作させる必要があるため、既存の build-and-test jobとは別個のjobを作って動作させることになると思います。

  • 可能であれば、そのようなActionsを追加してもらえますか?
  • Actionsの用意が難しければ、これら3つのテストを実行させるために必要な手順のドキュメントファイルを追加してもらえますか?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f323830 手間取ってしまったのですがActions上で確認することはできました。

Comment thread tests/render-on-docker.test.ts Outdated
Comment thread .github/workflows/test.yml Fixed
@u1f992
Copy link
Copy Markdown
Member Author

u1f992 commented May 13, 2026

e978f4a WSLにマウントされるWindows側ドライブのパスは設定で変更できることを知り、オプションで切り替えられるようにしました。https://learn.microsoft.com/en-us/windows/wsl/wsl-config#automount-settings
このため、プリセットとヘルパー関数のシグネチャをオプション引数を受け入れる形に変更しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants