forked from thinkdevcode/Docker-Alpine-wkhtmltopdf
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alpine 3.9, wkhtmltopdf 0.12.5 relase
- Loading branch information
Showing
3 changed files
with
111 additions
and
164 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,81 @@ | ||
FROM alpine:3.8 | ||
FROM alpine:3.9 | ||
MAINTAINER Anton Wahyu <[email protected]> | ||
|
||
ENV WKHTMLTOPDF_VERSION=ccf91a0 | ||
ENV WKHTMLTOPDF_VERSION=tags/0.12.5 | ||
# install qt build packages # | ||
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ | ||
&& apk update \ | ||
&& apk add gtk+ openssl glib fontconfig bash vim \ | ||
&& apk add --virtual .deps git patch make g++ \ | ||
libc-dev gettext-dev zlib-dev bzip2-dev libffi-dev pcre-dev \ | ||
glib-dev atk-dev expat-dev libpng-dev freetype-dev fontconfig-dev \ | ||
libxau-dev libxdmcp-dev libxcb-dev xf86bigfontproto-dev libx11-dev \ | ||
libxrender-dev pixman-dev libxext-dev cairo-dev perl-dev \ | ||
libxfixes-dev libxdamage-dev graphite2-dev icu-dev harfbuzz-dev \ | ||
libxft-dev pango-dev gtk+-dev libdrm-dev \ | ||
libxxf86vm-dev libxshmfence-dev wayland-dev mesa-dev openssl-dev \ | ||
&& git clone --recursive https://github.com/wkhtmltopdf/wkhtmltopdf.git /tmp/wkhtmltopdf \ | ||
&& cd /tmp/wkhtmltopdf \ | ||
&& git checkout $WKHTMLTOPDF_VERSION | ||
RUN apk update \ | ||
&& apk add gtk+ openssl glib fontconfig libstdc++ bash vim \ | ||
&& apk add --virtual .deps git patch make g++ \ | ||
libc-dev gettext-dev zlib-dev bzip2-dev libffi-dev pcre-dev \ | ||
glib-dev atk-dev expat-dev libpng-dev freetype-dev fontconfig-dev \ | ||
libxau-dev libxdmcp-dev libxcb-dev libx11-dev \ | ||
libxrender-dev pixman-dev libxext-dev cairo-dev perl-dev \ | ||
libxfixes-dev libxdamage-dev graphite2-dev icu-dev harfbuzz-dev \ | ||
libxft-dev pango-dev gtk+-dev libdrm-dev \ | ||
libxxf86vm-dev libxshmfence-dev wayland-dev mesa-dev openssl-dev \ | ||
&& git clone --recursive https://github.com/wkhtmltopdf/wkhtmltopdf.git /tmp/wkhtmltopdf \ | ||
&& cd /tmp/wkhtmltopdf \ | ||
&& git checkout $WKHTMLTOPDF_VERSION | ||
|
||
COPY conf/* /tmp/wkhtmltopdf/qt/ | ||
|
||
RUN cd /tmp/wkhtmltopdf/qt && \ | ||
patch -p1 -i qt-musl.patch && \ | ||
patch -p1 -i qt-musl-iconv-no-bom.patch && \ | ||
patch -p1 -i qt-recursive-global-mutex.patch && \ | ||
patch -p1 -i qt-gcc6.patch && \ | ||
sed -i "s|-O2|$CXXFLAGS|" mkspecs/common/g++.conf && \ | ||
sed -i "/^QMAKE_RPATH/s| -Wl,-rpath,||g" mkspecs/common/g++.conf && \ | ||
sed -i "/^QMAKE_LFLAGS\s/s|+=|+= $LDFLAGS|g" mkspecs/common/g++.conf && \ | ||
CFLAGS=-w CPPFLAGS=-w CXXFLAGS=-w LDFLAGS=-w \ | ||
./configure -confirm-license -opensource \ | ||
-prefix /usr \ | ||
-datadir /usr/share/qt \ | ||
-sysconfdir /etc \ | ||
-plugindir /usr/lib/qt/plugins \ | ||
-importdir /usr/lib/qt/imports \ | ||
-fast \ | ||
-release \ | ||
-static \ | ||
-largefile \ | ||
-glib \ | ||
-graphicssystem raster \ | ||
-qt-zlib \ | ||
-qt-libpng \ | ||
-qt-libmng \ | ||
-qt-libtiff \ | ||
-qt-libjpeg \ | ||
-svg \ | ||
-script \ | ||
-webkit \ | ||
-gtkstyle \ | ||
-xmlpatterns \ | ||
-script \ | ||
-scripttools \ | ||
-openssl-linked \ | ||
-nomake demos \ | ||
-nomake docs \ | ||
-nomake examples \ | ||
-nomake tools \ | ||
-nomake tests \ | ||
-nomake translations \ | ||
-no-qt3support \ | ||
-no-pch \ | ||
-no-icu \ | ||
-no-phonon \ | ||
-no-phonon-backend \ | ||
-no-rpath \ | ||
-no-separate-debug-info \ | ||
-no-dbus \ | ||
-no-opengl \ | ||
-no-openvg && \ | ||
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ | ||
export MAKEFLAGS=-j${NPROC} && \ | ||
export MAKE_COMMAND="make -j${NPROC}" && \ | ||
make --silent && \ | ||
make install && \ | ||
cd /tmp/wkhtmltopdf && \ | ||
sed -i -E "s|(.*)|\1@$WKHTMLTOPDF_VERSION" && \ | ||
qmake && \ | ||
make --silent && \ | ||
make install && \ | ||
rm -rf /tmp/* \ | ||
# remove qt build packages # | ||
&& apk del .deps \ | ||
&& rm -rf /var/cache/apk/* | ||
patch -p1 -i qt-musl.patch && \ | ||
patch -p1 -i qt-musl-iconv-no-bom.patch && \ | ||
patch -p1 -i qt-recursive-global-mutex.patch && \ | ||
patch -p1 -i qt-gcc8.patch && \ | ||
CFLAGS=-w CPPFLAGS=-w CXXFLAGS=-w LDFLAGS=-w \ | ||
./configure -confirm-license -opensource \ | ||
-prefix /usr \ | ||
-datadir /usr/share/qt \ | ||
-sysconfdir /etc \ | ||
-plugindir /usr/lib/qt/plugins \ | ||
-importdir /usr/lib/qt/imports \ | ||
-fast \ | ||
-release \ | ||
-static \ | ||
-largefile \ | ||
-glib \ | ||
-graphicssystem raster \ | ||
-qt-zlib \ | ||
-qt-libpng \ | ||
-qt-libmng \ | ||
-qt-libtiff \ | ||
-qt-libjpeg \ | ||
-svg \ | ||
-script \ | ||
-webkit \ | ||
-gtkstyle \ | ||
-xmlpatterns \ | ||
-script \ | ||
-scripttools \ | ||
-openssl-linked \ | ||
-nomake demos \ | ||
-nomake docs \ | ||
-nomake examples \ | ||
-nomake tools \ | ||
-nomake tests \ | ||
-nomake translations \ | ||
-no-qt3support \ | ||
-no-pch \ | ||
-no-icu \ | ||
-no-phonon \ | ||
-no-phonon-backend \ | ||
-no-rpath \ | ||
-no-separate-debug-info \ | ||
-no-dbus \ | ||
-no-opengl \ | ||
-no-openvg && \ | ||
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ | ||
export MAKEFLAGS=-j${NPROC} && \ | ||
export MAKE_COMMAND="make -j${NPROC}" && \ | ||
make --silent && \ | ||
make install && \ | ||
cd /tmp/wkhtmltopdf && \ | ||
qmake && \ | ||
make --silent && \ | ||
make install && \ | ||
rm -rf /tmp/* \ | ||
# remove qt build packages # | ||
&& apk del .deps \ | ||
&& rm -rf /var/cache/apk/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
#### Alpine Linux 3.6 wkhtmltopdf 0.12.5-dev (with patched qt) | ||
#### Alpine Linux 3.9 wkhtmltopdf 0.12.5 (with patched qt) | ||
|
||
Based on [alloylab/Docker-Alpine-wkhtmltopdf](https://github.com/alloylab/Docker-Alpine-wkhtmltopdf) | ||
|
||
Alpine has wkhtmltopdf package but with unpatched qt, therefor not all wkhtmltopdf features can be used. | ||
|
||
This container aim to build wkhtmltopdf and patched qt. | ||
|
||
Resulting binary from build process can be reused as long as glib and openssl packages is installed. | ||
Certain wkhtmltopdf features cant be used with Alpine default wkhtmlpdf package, qt is unpatched. This container aim to build wkhtmltopdf and patched qt. The binary in this container is using shared library that can be fulfilled with installing Alpine default wkhtmltopdf package | ||
|
||
Build step: | ||
|
||
``` | ||
docker build -t aantonw/wkhtmltohtml . | ||
docker run --name wkhtmltopdf -it aantonw/wkhtmltopdf html | ||
docker run --name wkhtmltopdf -it aantonw/wkhtmltopdf bash | ||
# copy build result to host | ||
docker cp wkhtmltopdf:/lib/libwkhtmltox.so.0.12.5 wkhtmltox.so.0.12.5 | ||
docker cp wkhtmltopdf:/bin/wkhtmltopdf wkhtmltopdf | ||
docker cp wkhtmltopdf:/bin/wkhtmltoimage wkhtmltoimage | ||
``` | ||
|
||
Using binary to replace default wkhtmltopdf via Dockerfile: | ||
|
||
``` | ||
FROM alpine:3.9 | ||
### install unpatched wkhtmltopdf | ||
RUN apk add --update wkhtmltopdf | ||
### replace binary and lib | ||
COPY wkhtmltopdf /usr/bin/wkhtmltopdf | ||
COPY wkhtmltoimage /usr/bin/wkhtmltoimage | ||
``` | ||
|
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