Skip to content

Instantly share code, notes, and snippets.

@cornernote
Last active April 30, 2021 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cornernote/09221c5896d36133c3f36ecc13c928aa to your computer and use it in GitHub Desktop.
Save cornernote/09221c5896d36133c3f36ecc13c928aa to your computer and use it in GitHub Desktop.
docker test for wkhtmltopdf

Play with Docker - WKHTMLTOPDF

There are many way to try out WKHTMLTOPDF, a really slick one is creating a stack on Play with Docker.

Login or signup, then create a new instance.

Download a Docker application definition:

curl -Lo docker-compose.yml https://gist.githubusercontent.com/cornernote/09221c5896d36133c3f36ecc13c928aa/raw/ca4c8504445fbc2c214250a49ffef506c08bd8c9/docker-compose.yml
curl -Lo Dockerfile https://gist.githubusercontent.com/cornernote/09221c5896d36133c3f36ecc13c928aa/raw/ca4c8504445fbc2c214250a49ffef506c08bd8c9/Dockerfile

Optionally build the stack

docker-compose build

Now try to generate PDFs

docker-compose run --rm wkhtmltopdf wkhtmltopdf google.com /app/test.pdf
docker-compose run --rm wkhtmltopdf wkhtmltopdf example.com /app/test.pdf
version: '2'
services:
wkhtmltopdf:
build:
dockerfile: Dockerfile
context: .
volumes:
- ./:/app
FROM debian:stretch
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install \
curl && \
## Install wkhtmltopdf
curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb \
-o wkhtmltox_0.12.6-1.stretch_amd64.deb && \
apt-get -y install \
wkhtmltopdf \
build-essential \
openssl \
libssl1.0-dev \
xorg \
xvfb && \
dpkg -i wkhtmltox_0.12.6-1.stretch_amd64.deb && \
rm -f wkhtmltox_0.12.6-1.stretch_amd64.deb && \
# Install mscorefonts
curl -L http://ftp.us.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.6_all.deb \
-o ttf-mscorefonts-installer_3.6_all.deb && \
apt-get -y install \
wget \
cabextract && \
dpkg -i ttf-mscorefonts-installer_3.6_all.deb && \
rm -f ttf-mscorefonts-installer_3.6_all.deb && \
# Cleanup
apt-get -y autoremove && \
apt-get clean
@cornernote
Copy link
Author

cornernote commented Apr 30, 2021 via email

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