marp-team/marp-cli

Server Mode Auto-refresh Does Not Work in Docker

julianprester opened this issue · 3 comments

I'm using the server mode with docker with the following command (taken directly from the docker hub usage example):

docker run --rm --init -v ${PWD}:/home/marp/app -e LANG=$LANG -p 8080:8080 -p 37717:37717 marpteam/marp-cli -s .

I am running Docker on Windows via WSL2.

The server works well and is accessible at http://localhost:8080. However, the auto-refresh feature does not seem to work. Is there anything I'm doing wrong or any way I can debug the issue better. I checked the developer console in the browser, but could not find anything unusual either.

There is a websocket request to port 37717 that receives a status code 101, but I am assuming that is normal?

The Javascript console also prints out a [Marp CLI] Observing the change of file....

Marp CLI attempts to track changes in Markdown files using chokidar and notify the browser through WebSocket when changes occur. It seems that the WebSocket connection has already been established, so the WSL file system may not emit file change events.

There is a known issue that WSL2 does not emit file change events when modifications are made from Windows.
microsoft/WSL#4739

Is auto-reloading working when you modify a Markdown file from WSL2 Linux?

Thanks a lot. That seems to be the issue.

Auto-reloading works when running the container from and making changes in WSL2 Linux.

I close the issue as it doesn't seem to be marp related.

I'm not yet tried but setting CHOKIDAR_USEPOLLING environment value as 1 may become a workaround.
https://github.com/paulmillr/chokidar?tab=readme-ov-file#performance

CHOKIDAR_USEPOLLING=1 marp -s .

Docker:

docker run --rm --init -v ${PWD}:/home/marp/app -e LANG=$LANG -e CHOKIDAR_USEPOLLING=1 -p 8080:8080 -p 37717:37717 marpteam/marp-cli -s .