symfony-docker icon indicating copy to clipboard operation
symfony-docker copied to clipboard

Wkhtmltopdf not working correctly with alpine

Open zairigimad opened this issue 3 years ago • 2 comments

Hello, while trying to install wkhtmltopdf with the following code

RUN apk add --no-cache wkhtmltopdf xvfb ttf-dejavu ttf-droid ttf-freefont ttf-liberation
RUN ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
RUN chmod +x /usr/local/bin/wkhtmltopdf

wkhtmltopdf not found in the alpine linux, when forcing alpine3.14 it does exist but it comes with wkhtmltopdf 0.12.6 wich is not working correctly with KnpSnappyBundle.

any idea how to install it correctly to have 0.12.5 version ?

thanks

zairigimad avatar Oct 05 '22 14:10 zairigimad

@zairigimad in our own docker images we do some magic like this

COPY --from=madnight/alpine-wkhtmltopdf-builder:0.12.5-alpine3.10 /bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
COPY --from=madnight/alpine-wkhtmltopdf-builder:0.12.5-alpine3.10 /bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage

but never tried if this works with symfony-docker

mario-fehr avatar Oct 05 '22 15:10 mario-fehr

Hello, I managed to install it in alpine by using the community repository v3.9 and specifying the version of wkhtmltopdf.

here is the change I made in DockerFile

RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.9/community" >> /etc/apk/repositories;

# Install wkhtmltopdf
RUN apk add --no-cache wkhtmltopdf=0.12.5-r0 xvfb ttf-dejavu ttf-droid ttf-freefont ttf-liberation
RUN ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
RUN chmod +x /usr/local/bin/wkhtmltopdf

I'm not sure if it's the best way to resolve it, but like this i can install it without depending on other docker image.

zairigimad avatar Oct 06 '22 10:10 zairigimad