Last active
May 4, 2022 15:52
-
-
Save FilBot3/cad8be9baaad1c56db532c7e4c13ae5a to your computer and use it in GitHub Desktop.
Buildah script to create a Mermaid.js CLI container image. I had issues pulling it earlier, so I made my own.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Fail on errors. | |
set -e | |
container=$(buildah from docker.io/library/node:alpine) | |
buildah config --env=CHROME_BIN="/usr/bin/chromium-browser" ${container} | |
buildah config --env=PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" ${container} | |
buildah run ${container} -- sh -c "apk add chromium font-noto-cjk font-noto-emoji terminus-font ttf-dejavu ttf-freefont ttf-font-awesome ttf-inconsolata ttf-linux-libertine && fc-cache -f" | |
buildah run ${container} -- adduser -D mermaidcli | |
buildah run --user=mermaidcli --workingdir=/home/mermaidcli ${container} -- sh -c 'yarn add @mermaid-js/mermaid-cli' | |
buildah run --user=mermaidcli --workingdir=/home/mermaidcli ${container} -- sh -c 'echo "{\"executablePath\": \"/usr/bin/chromium-browser\",\"args\":[\"--no-sandbox\"]}" | tee /home/mermaidcli/puppeteer-config.json' | |
buildah config --entrypoint='["/home/mermaidcli/node_modules/.bin/mmdc", "-p", "/home/mermaidcli/puppeteer-config.json"]' ${container} | |
buildah config --cmd="--help" ${container} | |
buildah config --label=RUN='podman run --rm --userns=keep-id --volume=".:/home/mermaidcli/files:Z" --workdir=/home/mermaidcli/files ${IMAGE} --input index.mmd' ${container} | |
buildah commit --rm --squash ${container} localhost/mmdc:latest | |
buildah images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to make sure that you don't run this in your$HOME directory. Fedora and SELinux will complain that you cannot remap your home directory. So, simply just put it in a different folder, can be just $ {HOME}/Documents/ and it will work.