Merge branch 'feature/diagram' into develop

This commit is contained in:
Jörn-Michael Miehe 2024-11-22 17:20:05 +01:00
commit 5119a9596b
7 changed files with 140 additions and 52 deletions

View file

@ -3,12 +3,33 @@ kind: pipeline
name: default name: default
steps: steps:
- name: docker - name: default
image: plugins/docker image: plugins/docker
settings: settings:
repo: ldericher/autodoc repo: ldericher/autodoc
auto_tag: true
username: username:
from_secret: DOCKER_USERNAME from_secret: DOCKER_USERNAME
password: password:
from_secret: DOCKER_PASSWORD from_secret: DOCKER_PASSWORD
auto_tag: true
dockerfile: Dockerfile.alpine
target: stage-base
- name: diagram
image: plugins/docker
settings:
repo: ldericher/autodoc
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
auto_tag: true
auto_tag_suffix: -diagram
dockerfile: Dockerfile.ubuntu
target: stage-diagram
- name: parallelism provider
image: alpine
depends_on:
- default
- diagrams

View file

@ -1,22 +0,0 @@
FROM pandoc/extra:latest
RUN set -ex; \
\
apk add --no-cache \
bash \
ghostscript \
inotify-tools \
make \
; \
\
tlmgr install \
kpfonts \
lastpage \
latexmk \
;
COPY src/usr /usr
WORKDIR /docs
ENTRYPOINT ["autodoc"]
CMD ["-bw"]

48
Dockerfile.alpine Normal file
View file

@ -0,0 +1,48 @@
FROM pandoc/extra:latest AS stage-base
RUN set -ex; \
\
apk add --no-cache \
bash \
ghostscript \
inotify-tools \
make \
; \
\
tlmgr install \
kpfonts \
lastpage \
latexmk \
;
COPY src/usr /usr
WORKDIR /docs
ENTRYPOINT ["autodoc"]
CMD ["-bw"]
FROM stage-base AS stage-diagram
ENV PUPPETEER_CACHE_DIR="/usr/local/share/puppeteer/cache" \
PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium-browser" \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
COPY src/diagram.lua.patch /usr/local/src/autodoc/diagram.lua.patch
RUN set -ex; \
\
apk add --no-cache \
chromium \
npm \
patch \
; \
\
npm install --global @mermaid-js/mermaid-cli; \
# rm -rf /root/.cache/puppeteer; \
\
wget \
--output-document='/usr/local/share/pandoc/filters/diagram.lua' \
'https://raw.githubusercontent.com/pandoc-ext/diagram/refs/heads/main/_extensions/diagram/diagram.lua' \
; \
patch /usr/local/share/pandoc/filters/diagram.lua < /usr/local/src/autodoc/diagram.lua.patch; \
rm /usr/local/src/autodoc/diagram.lua.patch;

55
Dockerfile.ubuntu Normal file
View file

@ -0,0 +1,55 @@
FROM pandoc/extra:latest-ubuntu AS stage-base
RUN set -ex; \
\
deluser --remove-home ubuntu; \
\
apt-get update; apt-get install --no-install-recommends --yes \
ghostscript \
inotify-tools \
make \
; rm -rf /var/lib/apt/lists/*; \
\
tlmgr install \
kpfonts \
lastpage \
latexmk \
;
COPY src/usr /usr
WORKDIR /docs
ENTRYPOINT ["autodoc"]
CMD ["-bw"]
FROM stage-base AS stage-diagram
ENV PUPPETEER_CACHE_DIR="/usr/local/share/puppeteer/cache"
COPY src/diagram.lua.patch /usr/local/src/autodoc/diagram.lua.patch
RUN set -ex; \
\
apt-get update; apt-get install --no-install-recommends --yes \
libasound2t64 \
libatk1.0-0t64 \
libatk-bridge2.0-0t64 \
libgbm1 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxrandr2 \
npm \
patch \
; rm -rf /var/lib/apt/lists/*; \
\
npm install --global @mermaid-js/mermaid-cli; \
\
wget \
--output-document='/usr/local/share/pandoc/filters/diagram.lua' \
'https://raw.githubusercontent.com/pandoc-ext/diagram/refs/heads/main/_extensions/diagram/diagram.lua' \
; \
patch /usr/local/share/pandoc/filters/diagram.lua < /usr/local/src/autodoc/diagram.lua.patch; \
rm /usr/local/src/autodoc/diagram.lua.patch;

View file

@ -1,28 +0,0 @@
image_tag = ldericher/autodoc
docker_build = docker build
docker_run = docker run --rm -it
examples_flags = -v "$(shell pwd)/examples:/docs" -u "$(shell id -u):$(shell id -g)"
.PHONY: default
default:
$(info use other targets: image build watch shell clean)
.PHONY: image
image:
$(docker_build) --tag $(image_tag) ./
.PHONY: build
build: image
$(docker_run) $(examples_flags) $(image_tag) -b
.PHONY: watch
watch: image
$(docker_run) $(examples_flags) $(image_tag)
.PHONY: shell
shell: image
$(docker_run) $(examples_flags) --entrypoint ash $(image_tag)
.PHONY: clean
clean:
git clean -xdf ./examples

11
src/diagram.lua.patch Normal file
View file

@ -0,0 +1,11 @@
--- diagram.lua 2024-11-18 23:55:02.673989033 +0100
+++ diagram.patched.lua 2024-11-19 00:10:14.359878550 +0100
@@ -158,7 +158,7 @@
write_file(infile, code)
pipe(
self.execpath or 'mmdc',
- {"--pdfFit", "--input", infile, "--output", outfile},
+ {"--pdfFit", "--puppeteerConfigFile", "/usr/local/share/puppeteer/config.json", "--input", infile, "--output", outfile},
''
)
return read_file(outfile), mime_type

View file

@ -0,0 +1,3 @@
{
"args": [ "--no-sandbox" ]
}