简体   繁体   中英

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

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

Did you use the from ? use

FROM ruby:2.5.1-alpine

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

Installing wkhtmltopdf from the alpine repo doesn't work in some cases due to a missing qt patches. Some images (eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM