Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FYI: Configuration for running mmdc via mermaid-cli docker image #27

Open
nickbp opened this issue Sep 28, 2022 · 3 comments
Open

FYI: Configuration for running mmdc via mermaid-cli docker image #27

nickbp opened this issue Sep 28, 2022 · 3 comments

Comments

@nickbp
Copy link

nickbp commented Sep 28, 2022

The following configuration will allow rendering mermaid charts without needing to install nodejs+mermaid-cli to the local OS. Instead it will execute mmdc via the mermaid-cli docker image. Figured it'd make sense to note this somewhere in case someone else found it useful:

(setq mermaid-mmdc-location "docker")
(setq mermaid-flags "run -u 1000 -v /tmp:/tmp ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:9.1.6")

Some explanation of the docker run arguments:

  • -u 1000 ensures that the resulting output png file has a matching UID to the current user, avoiding permissions issues when deleting or overwriting the png. The 1000 is my UID on my machine. There might be a way to figure out the UID directly in emacs.
  • -v /tmp:/tmp mounts the host /tmp to /tmp inside the container. This ensures that mmdc inside the container will be reading/writing to the host /tmp when rendering.
  • 9.1.6: Latest stable version as of this writing. Can check available tags here
@abrochard
Copy link
Owner

Thank you for sharing! I will add this to the readme.

Which docker image do you use? https://hub.docker.com/r/matthewfeickert/mermaid-cli ?

@nickbp
Copy link
Author

nickbp commented Sep 29, 2022

I've been using the "official" one on the GitHub container registry, ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:9.1.6 in the above example.

@nickbp
Copy link
Author

nickbp commented Sep 29, 2022

One catch I've just found is that the "current buffer" command works but the "current file" command doesn't work. I assume because the current file isn't necessarily visible to the docker container. The workaround would be to stick to the "current buffer" command where it writes the input to /tmp/current-buffer.mmd

abrochard added a commit that referenced this issue Sep 29, 2022
* Adding instructions on using mermaid-cli in docker

Thanks to #27 for the tips!

* Update README.md
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

No branches or pull requests

2 participants