Skip to content

Instantly share code, notes, and snippets.

@AlloVince
Created September 7, 2019 06:45
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 AlloVince/947a2d08bc934a592b6eb58cc6410fde to your computer and use it in GitHub Desktop.
Save AlloVince/947a2d08bc934a592b6eb58cc6410fde to your computer and use it in GitHub Desktop.
wkhtmltopdf microservice dockerfile
FROM mhart/alpine-node:8
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories
# Add bash support
RUN apk add --update bash && rm -rf /var/cache/apk/*
RUN apk add --no-cache \
xvfb \
# Additionnal dependencies for better rendering
ttf-freefont \
fontconfig \
dbus \
&& \
# Install wkhtmltopdf from `testing` repository
apk add qt5-qtbase-dev \
wkhtmltopdf \
--no-cache \
--repository http://mirrors.ustc.edu.cn/alpine/edge/testing/ \
--allow-untrusted \
&& \
# Wrapper for xvfb
mv /usr/bin/wkhtmltopdf /usr/bin/wkhtmltopdf-origin && \
echo $'#!/usr/bin/env sh\n\
Xvfb :0 -screen 0 1024x768x24 -ac +extension GLX +render -noreset & \n\
DISPLAY=:0.0 wkhtmltopdf-origin $@ \n\
killall Xvfb\
' > /usr/bin/wkhtmltopdf && \
chmod +x /usr/bin/wkhtmltopdf
RUN mkdir -p /usr/share/fonts/chinese/TrueType
COPY ./config/font/simsun.ttc /usr/share/fonts/chinese/TrueType
COPY . /opt/htdocs/htmltopdf
WORKDIR "/opt/htdocs/htmltopdf"
#RUN npm config set registry="https://registry.npm.taobao.org"
RUN npm install && npm run build && npm prune --production
CMD npm start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment