Created
December 14, 2018 18:52
-
-
Save rgpublic/1a721599332402f55625afc3886b967a to your computer and use it in GitHub Desktop.
pdf2svg static build docker file
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
# Install necessary packages | |
RUN apt-get install -y bsdtar | |
RUN apt-get install -y cmake | |
RUN apt-get install -y libfreetype6-dev | |
RUN apt-get install -y libfontconfig-dev | |
RUN apt-get install -y libjpeg-dev | |
RUN apt-get install -y libcairo-dev | |
RUN apt-get install -y libopenjp2-7-dev | |
RUN apt-get install -y libffi-dev | |
RUN apt-get install -y libtiff-dev | |
RUN apt-get install -y libmount-dev | |
RUN apt-get install -y libselinux1-dev | |
# Create simple BASH script to fetch stuff easier | |
# We use bsdtar instead of normal tar, because it can autodetect gz/xz files | |
# when reading from STDIN | |
RUN echo '#!/bin/bash' > get.sh | |
RUN echo 'mkdir "$2"' >> get.sh | |
RUN echo 'wget -O - "$1" | bsdtar -f - -x --strip-components=1 -C "$2"' >> get.sh | |
RUN chmod +x get.sh | |
# Download all required sources | |
RUN ./get.sh https://sourceforge.net/projects/lcms/files/lcms/2.9/lcms2-2.9.tar.gz lcms2 | |
RUN ./get.sh https://poppler.freedesktop.org/poppler-0.71.0.tar.xz poppler | |
RUN ./get.sh https://github.com/uclouvain/openjpeg/archive/v2.3.0.tar.gz openjpeg | |
RUN ./get.sh https://github.com/dawbarton/pdf2svg/archive/v0.2.3.tar.gz pdf2svg | |
# Compile/Install LCMS2. We need a static build which isnt provided by a package | |
WORKDIR lcms2 | |
RUN ./configure --enable-static --disable-shared | |
RUN make && make install | |
WORKDIR .. | |
# Compile/Install Poppler | |
# Build without NSS3 support. NSS3 doesnt work with static builds | |
WORKDIR poppler | |
RUN mkdir build | |
WORKDIR build | |
RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DENABLE_NSS3=OFF .. | |
RUN make && make install | |
WORKDIR ../.. | |
# Compile/Install OpenJPEG. We need a static build which isnt provided by a package | |
# There is not "make install" so we just copy the file to the right folder | |
WORKDIR openjpeg | |
RUN mkdir build | |
WORKDIR build | |
RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF .. | |
RUN make | |
RUN cp bin/libopenjp2.a /usr/local/lib | |
WORKDIR ../.. | |
# Finally, compile/install PDF2SVG as a static binary | |
# For static compilation to work, all dependencies have to be | |
# mentioned individually one by one for the linker. We use pkg-config | |
# to generate appropriate compiler and linker flags for most libraries. | |
# For some of them, this doesnt work and/or they must come | |
# at a specific argument position, so we list them separately. | |
WORKDIR pdf2svg | |
RUN echo '#!/bin/bash' > myconfig.sh | |
RUN echo 'pkgs="freetype2 poppler-cpp cairo lcms2 libopenjp2 libtiff-4 libffi pixman-1 glib-2.0 gio-2.0 gmodule-2.0 libpcre"' >> myconfig.sh | |
RUN echo 'flags="-lm -lstdc++ -lblkid"' >> myconfig.sh | |
RUN echo 'export CFLAGS="-static -pthread "`pkg-config --cflags --static $pkgs`" "$flags' >> myconfig.sh | |
RUN echo 'export LIBS="-static -pthread "`pkg-config --libs --static $pkgs`" "$flags' >> myconfig.sh | |
RUN echo './configure' >> myconfig.sh | |
RUN chmod +x myconfig.sh | |
RUN ./myconfig.sh | |
RUN make && make install | |
WORKDIR .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment