Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 \
Expand All @@ -31,11 +31,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
Comment on lines +70 to +73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a requirement of running mdbook, or a way to start a new bash environment? It doesn't look like puppeteer-config.json specifies any particular user. Oh, maybe it's just so it's run as a non-root user?


HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1

ENTRYPOINT ["mdbook"]
1 change: 1 addition & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
build:
context: .
target: release # build the release stage
platform: linux/amd64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this can still be run on a Mac M-Series device using ARM? It just won't be native and as fast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct!

ports:
- 3000:3000
- 3001:3001
Expand Down
3 changes: 3 additions & 0 deletions puppeteer-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"args": ["--no-sandbox", "--disable-setuid-sandbox"]
}