diff --git a/pdf-builder/Dockerfile b/pdf-builder/Dockerfile deleted file mode 100644 index 7855013..0000000 --- a/pdf-builder/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM alpine:3 - -RUN apk update \ - && apk add --no-cache \ - chromium \ - nodejs \ - npm \ - sed \ - bash \ - procps \ - font-noto-emoji \ - font-roboto-mono \ - font-roboto \ - font-terminus \ - font-inconsolata \ - font-dejavu \ - font-noto \ - font-noto-cjk \ - font-awesome \ - font-noto-extra \ - font-adobe-source-code-pro - -RUN npm install -g \ - chrome-headless-render-pdf \ - node-static - -COPY entrypoint.bash /usr/local/bin/entrypoint -COPY chrome-wrapper.bash /usr/local/bin/chrome-wrapper -COPY local.conf /etc/fonts/local.conf - -RUN mkdir /tmp/html-to-pdf \ - && chmod +x /usr/local/bin/* - -ARG WORKDIR="/workspace" -ENV WORKDIR="${WORKDIR}" - -WORKDIR "${WORKDIR}" - -ENTRYPOINT [ "/usr/local/bin/entrypoint" ] \ No newline at end of file diff --git a/pdf-builder/README.md b/pdf-builder/README.md deleted file mode 100644 index 9b73c11..0000000 --- a/pdf-builder/README.md +++ /dev/null @@ -1,63 +0,0 @@ -This is copied from https://github.com/pinkeen/docker-html-to-pdf/tree/master -Updated to support emoji based on https://github.com/Zenika/alpine-chrome/pull/115/commits/9418fddf6c39fd9e746e65f07d9c72191b708b97 - -# Convert html-to-pdf via dockerized chrome headless - -Because currently the `--print-to-pdf` CLI switch does not allow disabling of -header/footer the approach uses a nodejs script which connects to chrome via -remote interface. It also executes 5s of javascript (virtual time) to ensure -that the page is fully rendered. - -## BIG FAT WARNING - BREAKING CHANGES AHEAD! - -If you came here because the container stopped working for you then -probably you were using the `latest` tag instead of the stable versioned -image. - -The working directory has changed from `/tmp/html-to-pdf` to `/workspace`. It can -be changed via `WORKDIR` docker argument and environment variable of the same name. - -Additionally Alpine is now used instead of Ubuntu what has reduced the image size -from ~800MB to ~100MB. - -Also, there are a couple of additions: the built-in webserver, better logging -and all-over code remake. - -## How to run it? - -You need to mount the container's working directory (`/workspace`) locally -to be able to get the output file. - -``` -docker run -v "$(pwd):/workspace" pink33n/html-to-pdf --url http://google.com --pdf out.pdf -``` - -## Built-in static webserver - -The `/workspace` directory is served on port 80, so you can render files from -the directory mounted to this volume by using `http://localhost/filename.html`. - -## Chrome arguments - -Chrome is started with these flags (beware, this may be unsecure in some rare circumstances!). - -``` ---no-sandbox --headless --disable-gpu --disable-web-security -–allow-file-access-from-files -``` - -This means that `file://` should also work, nevertheless, using the built-in web -server is recommended instead. - -Also expired certificates should no longer be a problem and completely break -some of the functionality like before. - -## Commandline arguments and the software that made this possible - -For all of the commandline arguments please check out the documentation for the library doing the actual heavy lifting: - -[chrome-headless-render](https://github.com/Szpadel/chrome-headless-render-pdf). - - -## Ansible - -[ansible-html-to-pdf](https://github.com/pinkeen/ansible-html-to-pdf) diff --git a/pdf-builder/chrome-wrapper.bash b/pdf-builder/chrome-wrapper.bash deleted file mode 100644 index d1dea6c..0000000 --- a/pdf-builder/chrome-wrapper.bash +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -e - -CMD="$(echo $CMD | sed -E 's/--no-sandbox|--disable-gpu|--headless|--disable-web-security|-–allow-file-access-from-files//gi')" -CMD="/usr/bin/chromium-browser --no-sandbox --headless --disable-gpu --disable-web-security -–allow-file-access-from-files $@" - -echo "Running chrome using: $CMD" - -$CMD \ No newline at end of file diff --git a/pdf-builder/entrypoint.bash b/pdf-builder/entrypoint.bash deleted file mode 100644 index 98c22ab..0000000 --- a/pdf-builder/entrypoint.bash +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -set -e - -VER_STATIC="$(static --version | sed -E 's/.*static ([0-9\.]+).*/\1/gi')" -VER_CHROME="$(chromium-browser --version | sed -E 's/.*Chromium ([0-9a-z\.]+).*/\1/gi')" -VER_NODE="$(node --version | sed -E 's/.*v([0-9a-z\.]+).*/\1/gi')" -VER_RENDER="$(npm info chrome-headless-render-pdf .version)" - -WORKDIR="${WORKDIR:-`pwd`}" - -STATIC_PORT="${STATIC_PORT:-80}" -STATIC_ROOT="${STATIC_ROOT:-$WORKDIR}" - -export SCRIPT_PID="$$" - -trap "cleanup; exit 0" 10 EXIT SIGTERM SIGHUP -trap "cleanup; exit 1" 11 - -cleanup() { - echo "--- Cleaning up..." - - [ -z "$(jobs -p)" ] || kill -9 `jobs -p` 2>/dev/null -} - -fatal() { - echo -e "\n--- FATAL: $@" >&2 - kill -11 $SCRIPT_PID -} - -quit() { - echo -e "\n--- Quitting..." - kill -10 $SCRIPT_PID -} - -info() { - echo -e "\n---- Environment info\n" - - echo "Workdir: $WORKDIR" - - echo "Chrome: $VER_CHROME" - echo "NodeJS: $VER_NODE" - echo "Static: $VER_STATIC" - echo "RenderPDF: $VER_RENDER" -} - -serve() { - echo -e "\n--- Starting static webserver\n" - - echo "Port: $STATIC_PORT" - echo "Root: $STATIC_ROOT" - - static -p $STATIC_PORT "$STATIC_ROOT" | sed -E 's/^/[serve] > /g' & - - local PID=$! - local WAIT=0 - - until kill -0 $PID 2>/dev/null ; do - (( WAIT>10 )) && fatal "Static webserver failed to start!" - (( WAIT+=1 )) - echo "--- Waiting for static webserver to start..." - sleep 0.1s - done -} - -render() { - local CMD="chrome-headless-render-pdf --chrome-binary=/usr/local/bin/chrome-wrapper $@" - - echo -e "\n--- Running render: $CMD \n" - $CMD | sed -E 's/^/[render] > /g' -} - -info -serve -render $@ -quit - diff --git a/pdf-builder/local.conf b/pdf-builder/local.conf deleted file mode 100644 index cefef3d..0000000 --- a/pdf-builder/local.conf +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - sans-serif - - Noto Serif - Noto Color Emoji - Noto Emoji - - - - - serif - - Roboto - Noto Color Emoji - Noto Emoji - - - - - monospace - - Source Code Pro - Noto Color Emoji - Noto Emoji - - - - diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c811331..0000000 Binary files a/requirements.txt and /dev/null differ