Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install wkhtmltopdf on Docker Ruby-2.5.1 Alpine Linux?

RUN apk --update add ttf-ubuntu-font-family wkhtmltopdf

I am trying to install wkhtml using this command on docker image ruby-2.5.1:alpine but error is:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  wkhtmltopdf (missing):
    required by: world[wkhtmltopdf]
The command '/bin/sh -c apk --update add ttf-ubuntu-font-family wkhtmltopdf' returned a non-zero code: 1

is there any way to install it? thanks in advance

like image 779
George Avatar asked Oct 23 '25 05:10

George


2 Answers

Update your base image, seem like it pulling from v3.7, as you can see the error

fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz

Where v3.7 does not contain wkhtmltopdf

v3.7 wkhtmltopdf not exist

or if you do not want update the image then you can install it from v3.10 wkhtmltopdf

RUN apk add  --no-cache --repository  http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ wkhtmltopdf=0.12.5-r0

Btw this base image will work without modification.

2.5-alpine3.9

like image 104
Adiii Avatar answered Oct 25 '25 17:10

Adiii


Installing wkhtmltopdf from the alpine repo doesn't work in some cases due to a missing qt patches. Some images (e.g. https://github.com/madnight/docker-alpine-wkhtmltopdf) have the patches applied and it's possible to use the patched binary as:

FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf_image

FROM ruby-alpine

COPY --from=wkhtmltopdf_image /bin/wkhtmltopdf /bin/

See also: https://github.com/mileszs/wicked_pdf/issues/841

like image 26
thisismydesign Avatar answered Oct 25 '25 18:10

thisismydesign



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!