Created
September 7, 2019 06:45
wkhtmltopdf microservice dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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