asciidoctor-diagram
asciidoctor-diagram copied to clipboard
asciidoctor-diagram + mermaid in docker container
I'm builded docker container from ubuntu:20.04
worker@215d607897f7:~/docs$ gem list|grep asciidoctor
asciidoctor (2.0.10)
asciidoctor-diagram (2.0.5)
asciidoctor-pdf (1.5.3)
worker@215d607897f7:~/docs$ npm -v
6.14.4
worker@215d607897f7:~/docs$ ./node_modules/.bin/mmdc --version
8.8.2-beta.8
and I got error:
asciidoctor -r asciidoctor-diagram ./components.adoc
asciidoctor: ERROR: components.adoc: line 17: Failed to generate image: node failed: internal/process/promises.js:182
throw err;
^
Error: Failed to launch the browser process!
[1027/110307.024283:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x55da00d5b3d9 base::debug::CollectStackTrace()
#1 0x55da00cd08b3 base::debug::StackTrace::StackTrace()
#2 0x55da00ce21f0 logging::LogMessage::~LogMessage()
#3 0x55d9ff3c2e0e content::ZygoteHostImpl::Init()
#4 0x55da008945b8 content::ContentMainRunnerImpl::Initialize()
#5 0x55da0089267c content::RunContentProcess()
#6 0x55da008927cc content::ContentMain()
#7 0x55da008e50b2 headless::(anonymous namespace)::RunContentMain()
#8 0x55da008e4d9c headless::HeadlessShellMain()
#9 0x55d9fe0b0e43 ChromeMain
#10 0x7f01d1e5c0b3 __libc_start_main
#11 0x55d9fe0b0c6a _start
Received signal 6
#0 0x55da00d5b3d9 base::debug::CollectStackTrace()
#1 0x55da00cd08b3 base::debug::StackTrace::StackTrace()
#2 0x55da00d5af7b base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f01d36403c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so+0x153bf)
#4 0x7f01d1e7b18b gsignal
#5 0x7f01d1e5a859 abort
#6 0x55da00d59ed5 base::debug::BreakDebugger()
#7 0x55da00ce264b logging::LogMessage::~LogMessage()
#8 0x55d9ff3c2e0e content::ZygoteHostImpl::Init()
#9 0x55da008945b8 content::ContentMainRunnerImpl::Initialize()
#10 0x55da0089267c content::RunContentProcess()
#11 0x55da008927cc content::ContentMain()
#12 0x55da008e50b2 headless::(anonymous namespace)::RunContentMain()
#13 0x55da008e4d9c headless::HeadlessShellMain()
#14 0x55d9fe0b0e43 ChromeMain
#15 0x7f01d1e5c0b3 __libc_start_main
#16 0x55d9fe0b0c6a _start
r8: 0000000000000000 r9: 00007ffcc36a8d50 r10: 0000000000000008 r11: 0000000000000246
r12: 00007ffcc36aa020 r13: 00007ffcc36a8fb0 r14: 00007ffcc36aa030 r15: aaaaaaaaaaaaaaaa
di: 0000000000000002 si: 00007ffcc36a8d50 bp: 00007ffcc36a8fa0 bx: 00007f01d0b15d80
dx: 0000000000000000 ax: 0000000000000000 cx: 00007f01d1e7b18b sp: 00007ffcc36a8d50
ip: 00007f01d1e7b18b efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at Interface.helper_js_1.helper.addEventListener (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
at Interface.emit (events.js:203:15)
at Interface.close (readline.js:397:8)
at Socket.onend (readline.js:173:10)
at Socket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
How I can fix this?
No idea I'm afraid. Seems like this is related to https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
Would it be possible to run mmdc with some additional config as described here: https://github.com/mermaidjs/mermaid.cli#linux-sandbox-issue ?
Okay, to whoever faces this issue. I did a small workaround in our ci/cd job:
function chrome_workaround() {
# https://github.com/mermaid-js/mermaid-cli/blob/master/docs/linux-sandbox-issue.md
mv /usr/local/bin/mmdc /usr/local/bin/mmdc-original
cat << 'EOF' > /usr/local/bin/puppeteer-config.json
{"args":["--no-sandbox"]}
EOF
cat << 'EOF' > /usr/local/bin/mmdc
#!/usr/bin/env bash
mmdc-original -p /usr/local/bin/puppeteer-config.json "$@"
EOF
chmod +x /usr/local/bin/mmdc
}
It's ugly but it works. You might need to adjust path to mmdc
since it might depend on the installation method.
@lazystone you should be able to apply this same workaround by passing the path to the puppeteer config file using the puppeteer-config
block attribute or mermaid-puppeteer-config
at the document level. Still not ideal but might be preferable over a wrapper mmdc script.
Thanks @pepijnve that's much better:
Create puppeteer-config.json
at the root of the project:
{
"args": [
"--no-sandbox"
]
}
In the build.gradle.kts
:
tasks.asciidoctor {
dependsOn("test")
attributes(
mapOf(
"snippets" to "$snippetsDir",
"srcDir" to file("src"),
// https://github.com/asciidoctor/asciidoctor-diagram/issues/302
"mermaid-puppeteer-config" to file("puppeteer-config.json"),
"mermaid-theme" to "forest"
)
)
}
Is it completed due to one of the above workarounds, or the issue fixed in the source image https://hub.docker.com/r/asciidoctor/docker-asciidoctor?