Skip to content

Instantly share code, notes, and snippets.

@rfdonnelly
Last active September 18, 2021 04:43
Show Gist options
  • Save rfdonnelly/54d03da075ecadf96eb6d944db7fc8de to your computer and use it in GitHub Desktop.
Save rfdonnelly/54d03da075ecadf96eb6d944db7fc8de to your computer and use it in GitHub Desktop.
docker-asciidoctor-web-pdf

docker-asciidoctor-web-pdf

Notes on creating a Docker image for asciidoctor-web-pdf.

Attempt 1

asciidoctor-web-pdf does not provide a Docker image. However, it does provide binaries. Strategy: start from asciidoctor/docker-asciidoctor:1.11 and layer in the asciidoctor-web-pdf v1.0.0-alpha.12 binary.

However, this binary is not compatible with Alpine Linux.

Ok so tell pkg to create an Alpine image:

diff --git a/tasks/prepare-binaries.js b/tasks/prepare-binaries.js
index cb011d9..aaf22bb 100644
--- a/tasks/prepare-binaries.js
+++ b/tasks/prepare-binaries.js
@@ -13,6 +13,7 @@ const buildDirPath = path.join(__dirname, '..', buildDir)
 // Can specify linux/mac/win as first argument to only build one of these platforms

 const platforms = {
+  alpine: {target: 'node12-alpine-x64', puppeteerPlatform: 'linux' },
   linux: { target: 'node12-linux-x64' },
   mac: { target: 'node12-macos-x64' },
   win: { target: 'node12-win-x64', suffix: '.exe', puppeteerPlatform: 'win64' }

This fixes the pkg generated binary however the chromium binary is not compatible with Alpine Linux and no chromium snapshots are provided for Alpine.

Possible Solution

Alpine provides chromium. However, puppeteer and chromium versions are tightly coupled. A specific version of puppeteer requires a specific version of chromium.

Use the version of chromium provided by Alpine then explicitly use the version of puppeteer compatible with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment