-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDockerfile
More file actions
109 lines (97 loc) · 5.39 KB
/
Copy pathDockerfile
File metadata and controls
109 lines (97 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# markup-antora — one Antora image to use everywhere.
#
# Consolidates the best of the ~9 Antora images that grew across the
# projects tree. Design priorities, in order:
# 1. Mermaid rendered FULLY OFFLINE — no Kroki server, no kroki.io,
# no CDN at build time and none at view time. Diagrams are baked
# to inline SVG by mermaid-cli (Alpine Chromium + Puppeteer)
# through the local-mermaid-extension.js Asciidoctor block
# processor, with content-hash caching so repeated diagrams render
# once per build.
# 2. Works under `--user $(id -u):$(id -g)` (rootless) without the
# Chromium crashpad / cosmiconfig EACCES failures.
# 3. Offline extras available but not forced: lunr full-text search,
# a pre-baked Antora UI bundle, and MathJax es5 for LaTeX.
# 4. asciidoctor-kroki installed-but-unused as an escape hatch.
FROM node:20-alpine@sha256:fb4cd12c85ee03686f6af5362a0b0d56d50c58a04632e6c0fb8363f609372293
LABEL org.opencontainers.image.title="markup-antora" \
org.opencontainers.image.description="Universal Antora site generator with offline Mermaid (mermaid-cli), offline search (lunr), pre-baked UI bundle + MathJax. No Kroki, no CDN." \
org.opencontainers.image.source="https://github.com/SKaiNET-developers/SKaiNET"
# Chromium for mermaid-cli (Puppeteer). Full font set so diagram labels,
# emoji and CJK render correctly (merged from the Daily-StandAPP image).
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ttf-freefont \
font-noto \
font-noto-emoji \
ca-certificates \
git
# HOME=/tmp: Chromium's crashpad handler writes its database under $HOME
# and aborts with `--database is required` when the container runs as a
# non-root --user and $HOME falls back to `/` (no passwd entry, not
# writable). Same motivation as runtime.cache_dir in the playbook.
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
PUPPETEER_SKIP_DOWNLOAD=true \
HOME=/tmp
# Install Antora + tooling into /opt/antora (NOT /antora, which is where
# the project gets volume-mounted at run time).
# - @mermaid-js/mermaid-cli : offline diagram rendering (the point)
# - @antora/lunr-extension : offline full-text search
# - asciidoctor-kroki : escape hatch only; the playbook should
# use the local mermaid extension instead.
# antora/cli: aa33c8283f9cbc76df93201bec5f8421e8f59a43 -> v3.1.15
# antora/site-generator: aa33c8283f9cbc76df93201bec5f8421e8f59a43 -> v3.1.15
# antora/lunr-extension: 41975fc8f62cb2219a2de2f618de1ae1482bd0ce -> v1.0.0-alpha.8
# mermaid-js/mermaid-cli: a85b11df7064498d5b6b97ee9b2d4a7c10cb42ae -> v11.16.0
# asciidoctor-kroki: d02fbf06cdb837524f5e4e12537c05e0bb83c715 -> v0.18
WORKDIR /opt/antora
RUN npm init -y && npm i --save-exact \
@antora/cli@3.1.15 \
@antora/site-generator@3.1.15 \
https://gitlab.com/antora/antora-lunr-extension.git#41975fc8f62cb2219a2de2f618de1ae1482bd0ce \
https://github.com/mermaid-js/mermaid-cli.git#a85b11df7064498d5b6b97ee9b2d4a7c10cb42ae \
https://github.com/asciidoctor/asciidoctor-kroki.git#d02fbf06cdb837524f5e4e12537c05e0bb83c715 \
&& npm cache clean --force
# Make installed modules resolvable even when the workdir is the mounted
# project (which has no node_modules of its own).
ENV NODE_PATH=/opt/antora/node_modules
# Mermaid-cli / Puppeteer config and the offline block processor, baked
# in at absolute paths the playbook can reference without mount gymnastics.
COPY puppeteer-config.json /opt/antora/puppeteer-config.json
COPY local-mermaid-extension.js /opt/antora/local-mermaid-extension.js
# --- Offline assets (available, not forced) -------------------------------
# Pre-download the default Antora UI bundle so sites build without hitting
# gitlab.com. Reference it from a playbook with:
# ui:
# bundle:
# url: /opt/antora-ui/ui-bundle.zip
# snapshot: true
RUN mkdir -p /opt/antora-ui \
&& wget -q -O /opt/antora-ui/ui-bundle.zip \
"https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable"
# Pre-download MathJax es5 for offline LaTeX. Copy /opt/mathjax/es5 into a
# supplemental UI or reference it from your UI template for client-side math.
# MathJax 600692ad9d3552cc25f85510d5797bc942ecc9f7 (600692a): v3.2.2
RUN mkdir -p /opt/mathjax \
&& npm pack git+https://github.com/mathjax/MathJax.git#600692a --pack-destination /tmp \
&& tar -xzf /tmp/mathjax-*.tgz -C /tmp \
&& cp -r /tmp/package/es5 /opt/mathjax/es5 \
&& rm -rf /tmp/mathjax-* /tmp/package
# --- Build-time smoke test + rootless cleanup -----------------------------
# Verify mermaid-cli works end to end so a broken image fails the build,
# not the user's first run. The cleanup also removes the mode-0700
# root-owned dirs (/tmp/.config/puppeteer, /tmp/.local/share/chromium,
# /tmp/.cache, /tmp/.npm) that Puppeteer/Chromium drop into $HOME during
# this run — leaving them would make cosmiconfig EACCES when the container
# is later launched with a non-root --user.
RUN echo 'graph TD; A-->B;' > /tmp/test.mmd \
&& /opt/antora/node_modules/.bin/mmdc \
-i /tmp/test.mmd -o /tmp/test.svg \
-p /opt/antora/puppeteer-config.json --quiet \
&& rm -rf /tmp/test.mmd /tmp/test.svg /tmp/.config /tmp/.local /tmp/.npm /tmp/.cache
WORKDIR /antora
ENTRYPOINT ["/opt/antora/node_modules/.bin/antora"]
CMD ["--stacktrace", "antora-playbook.yml"]