phpdockerwkhtmltopdfphpwkhtmltopdf

wkhtmltopdf with php:8-fpm-alpine


I have an existing php:8-fpm-alpine Dockerfile, and i need to add WKHTMLTOPDF package. Is that even possible. I tried using following dockerfile, but i get following error log:

Dockerfile...

FROM php:8-fpm-alpine
...
RUN apk add xvfb libfontconfig wkhtmltopdf

error:

ERROR [ 8/13] RUN apk add --no-cache wkhtmltopdf                                                                                                   2.1s

[ 8/13] RUN apk add --no-cache wkhtmltopdf:
#12 0.567 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
#12 1.097 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
#12 2.001 ERROR: unable to select packages:
#12 2.034   wkhtmltopdf (no such package):
#12 2.034     required by: world[wkhtmltopdf]

executor failed running [/bin/sh -c apk add --no-cache wkhtmltopdf]: exit code: 1
ERROR: Service 'php' failed to build : Build failed

I tried including contents from following repository, but i think its way too much work for 1 package, and it breaks in build process: https://github.com/alloylab/Docker-Alpine-wkhtmltopdf

Any help would be appreciated.


Solution

  • I faced a similar problem with php:7.4-fpm-alpine image.

    It seems like wkhtmltopdf is missing in Alpine v.3.15, but it is available in v.3.14.

    Try to change

    FROM php:8-fpm-alpine
    

    to

    FROM php:8-fpm-alpine3.14