From dd96c4852b4e0d6f0955626f7f92e1a4aae7e605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 18 Nov 2024 20:16:36 +0100 Subject: [PATCH 1/5] ubuntu base variant --- Dockerfile => Dockerfile.alpine | 0 Dockerfile.ubuntu | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) rename Dockerfile => Dockerfile.alpine (100%) create mode 100644 Dockerfile.ubuntu diff --git a/Dockerfile b/Dockerfile.alpine similarity index 100% rename from Dockerfile rename to Dockerfile.alpine diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 0000000..518b064 --- /dev/null +++ b/Dockerfile.ubuntu @@ -0,0 +1,38 @@ +FROM pandoc/extra:latest-ubuntu AS stage-base + +RUN set -ex; \ + \ + deluser --remove-home ubuntu; \ + \ + apt-get update; apt-get install -y \ + 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-diagrams + +RUN set -ex; \ + \ + apt-get update; apt-get install -y \ + npm \ + ; 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' \ + ; From f3219e947707aeef9ca5cf9b9844e45f4fcb36a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 18 Nov 2024 23:33:28 +0100 Subject: [PATCH 2/5] merge changes from workstation "Mustafa": - add ubuntu libraries - remove unused Makefile --- Dockerfile.ubuntu | 10 ++++++++++ Makefile | 28 ---------------------------- 2 files changed, 10 insertions(+), 28 deletions(-) delete mode 100644 Makefile diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 518b064..5b2f55f 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -27,6 +27,16 @@ FROM stage-base AS stage-diagrams RUN set -ex; \ \ apt-get update; apt-get install -y \ + libasound2t64 \ + libatk1.0-0t64 \ + libatk-bridge2.0-0t64 \ + libgbm1 \ + libnss3 \ + libxcomposite1 \ + libxdamage1 \ + libxfixes3 \ + libxkbcommon0 \ + libxrandr2 \ npm \ ; rm -rf /var/lib/apt/lists/*; \ \ diff --git a/Makefile b/Makefile deleted file mode 100644 index de98246..0000000 --- a/Makefile +++ /dev/null @@ -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 \ No newline at end of file From 91699e95ca9a5d9bebebbc7ab31aecbc5469db75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 19 Nov 2024 00:24:09 +0100 Subject: [PATCH 3/5] puppeteer configuration --- Dockerfile.ubuntu | 15 +++++++++++---- src/diagram.lua.patch | 11 +++++++++++ src/usr/local/share/puppeteer/config.json | 3 +++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/diagram.lua.patch create mode 100644 src/usr/local/share/puppeteer/config.json diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 5b2f55f..0079be1 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -4,7 +4,7 @@ RUN set -ex; \ \ deluser --remove-home ubuntu; \ \ - apt-get update; apt-get install -y \ + apt-get update; apt-get install --no-install-recommends --yes \ ghostscript \ inotify-tools \ make \ @@ -22,11 +22,15 @@ WORKDIR /docs ENTRYPOINT ["autodoc"] CMD ["-bw"] -FROM stage-base AS stage-diagrams +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 -y \ + apt-get update; apt-get install --no-install-recommends --yes \ libasound2t64 \ libatk1.0-0t64 \ libatk-bridge2.0-0t64 \ @@ -38,6 +42,7 @@ RUN set -ex; \ libxkbcommon0 \ libxrandr2 \ npm \ + patch \ ; rm -rf /var/lib/apt/lists/*; \ \ npm install --global @mermaid-js/mermaid-cli; \ @@ -45,4 +50,6 @@ RUN set -ex; \ 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; diff --git a/src/diagram.lua.patch b/src/diagram.lua.patch new file mode 100644 index 0000000..3e991d7 --- /dev/null +++ b/src/diagram.lua.patch @@ -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 diff --git a/src/usr/local/share/puppeteer/config.json b/src/usr/local/share/puppeteer/config.json new file mode 100644 index 0000000..a701bc4 --- /dev/null +++ b/src/usr/local/share/puppeteer/config.json @@ -0,0 +1,3 @@ +{ + "args": [ "--no-sandbox" ] +} From 5b8786fb336fa5ee2c56b4f99976025437d511b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 19 Nov 2024 01:48:10 +0100 Subject: [PATCH 4/5] experimental alpine support for diagram feature (sometimes hangs?) --- Dockerfile.alpine | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index faacd0c..312b5db 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM pandoc/extra:latest +FROM pandoc/extra:latest AS stage-base RUN set -ex; \ \ @@ -20,3 +20,29 @@ 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; From 2aa936e91705844fcd2718b5809c1246337d199e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 22 Nov 2024 17:19:52 +0100 Subject: [PATCH 5/5] CI --- .drone.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index a5119a0..6d7940e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,12 +3,33 @@ kind: pipeline name: default steps: -- name: docker +- name: default image: plugins/docker settings: repo: ldericher/autodoc - auto_tag: true username: from_secret: DOCKER_USERNAME 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