From 973e21aaec185b294724dbf2fabfeb37deb23b8a Mon Sep 17 00:00:00 2001 From: cusma Date: Wed, 24 Sep 2025 18:31:02 +0200 Subject: [PATCH 1/4] chore: add mermaid-filter --- book.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/book.toml b/book.toml index a3ef3889..900a207b 100644 --- a/book.toml +++ b/book.toml @@ -31,6 +31,7 @@ optional = true [output.pandoc.profile.pdf] output-file = "algorand-specs.pdf" pdf-engine = "lualatex" +filters = ["mermaid-filter"] [output.pandoc.profile.pdf.variables] mainfont = "Noto Serif" From 324cc2fbcd6e315ea4e8258ddee0b1214d28bc07 Mon Sep 17 00:00:00 2001 From: cusma Date: Wed, 24 Sep 2025 18:31:43 +0200 Subject: [PATCH 2/4] chore: specify platform for mdbook-release service --- docker-compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 67212660..45739b5e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,6 +17,7 @@ services: build: context: . target: release # build the release stage + platform: linux/amd64 ports: - 3000:3000 - 3001:3001 From c75d3129364d170449516fb2b550d4c41c1c76bd Mon Sep 17 00:00:00 2001 From: cusma Date: Wed, 24 Sep 2025 18:36:17 +0200 Subject: [PATCH 3/4] feat: add npm, browser dependencies, puppeteer config, non-root user --- Dockerfile | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eabb04e1..5cf99ef5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ FROM base AS ci-cd HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1 ENTRYPOINT ["mdbook"] -# Release image ---- +# Release image FROM base AS release RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -28,11 +28,47 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ fonts-noto \ fonts-noto-color-emoji \ librsvg2-bin \ + npm \ + libnss3 \ + libnspr4 \ + libdbus-1-3 \ + libatk1.0-0 \ + libatk-bridge2.0-0 \ + libcups2 \ + libdrm2 \ + libxkbcommon0 \ + libxcomposite1 \ + libxdamage1 \ + libxfixes3 \ + libxrandr2 \ + libgbm1 \ + libasound2 \ + libxshmfence1 \ && rm -rf /var/lib/apt/lists/* \ && fc-cache -fv +# Set a shared cache directory for Puppeteer's browser download +ENV PUPPETEER_CACHE_DIR /usr/local/share/puppeteer_cache + +RUN npm install --global mermaid-filter RUN cargo install mdbook-pandoc +COPY puppeteer-config.json /etc/puppeteer-config.json + +# Define the path to the mmdc executable +ARG MMD_PATH="/usr/local/lib/node_modules/mermaid-filter/node_modules/.bin" + +# Wrap the real mmdc executable to inject the config file option +RUN mv "${MMD_PATH}/mmdc" "${MMD_PATH}/mmdc-original" && \ + echo "#!/bin/sh" > "${MMD_PATH}/mmdc" && \ + echo "exec \"${MMD_PATH}/mmdc-original\" --puppeteerConfigFile /etc/puppeteer-config.json \"\$@\"" >> "${MMD_PATH}/mmdc" && \ + chmod +x "${MMD_PATH}/mmdc" + +RUN useradd --create-home --shell /bin/bash appuser +RUN chown -R appuser:appuser /book +RUN chmod 644 /etc/puppeteer-config.json +USER appuser + HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1 ENTRYPOINT ["mdbook"] \ No newline at end of file From 7d05b1f1649c186dafd4ddb618f8bd929d25ee46 Mon Sep 17 00:00:00 2001 From: cusma Date: Wed, 24 Sep 2025 18:36:43 +0200 Subject: [PATCH 4/4] chore: add puppeteer-config.json --- puppeteer-config.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 puppeteer-config.json diff --git a/puppeteer-config.json b/puppeteer-config.json new file mode 100644 index 00000000..411c0e79 --- /dev/null +++ b/puppeteer-config.json @@ -0,0 +1,3 @@ +{ + "args": ["--no-sandbox", "--disable-setuid-sandbox"] +} \ No newline at end of file