我用以下命令在Alpine Docker上安装了Wkhtmltopdf:
apk add --no-cache wkhtmltopdf
但是,当我尝试运行wkhtmltopdf时,我得到:
/usr/bin/wkhtmltopdf "test.html" "test.pdf"
Cannot mix incompatible Qt library (version 0x50c03) with this library (version 0x50c00)
Aborted (core dumped)
我该如何解决这个问题?
编辑:
似乎问题是其他一些软件包安装不兼容的qt版本。这是我的 Dockerfile:
RUN apk --no-cache update
&& apk --no-cache upgrade
&& apk add --no-cache
mysql-client
php7-mysqli
php7-pdo
freetype
libpng
freetype-dev
libpng-dev
jpeg-dev
libjpeg
libjpeg-turbo-dev
wget
zlib-dev
ttf-freefont
fontconfig
xvfb
libxrender-dev
gettext
gettext-dev
libxml2-dev
gnu-libiconv-dev
autoconf
g++
git
bash
wkhtmltopdf
您无法从 3.15 版本 https://pkgs.alpinelinux.org/packages?name=wkhtmltopdf&branch=edge&repo=&arch=&maintainer= 开始从 alpine 存储库安装 wkhtmltopdf
如果你想在较新的高山中使用wkhtmltopdf(下面的3.17(。您可以从其他映像(如 https://github.com/Surnet/docker-wkhtmltopdf(复制 bin 文件并安装相关库。
这是Dockerfile:
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
FROM php:8.2-fpm-alpine3.17 AS app
# wkhtmltopdf install dependencies
RUN apk add --no-cache
libstdc++
libx11
libxrender
libxext
libssl1.1
ca-certificates
fontconfig
freetype
ttf-droid
ttf-freefont
ttf-liberation
# more fonts
;
# wkhtmltopdf copy bins from ext image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/
# install php extensions, apache/nginx etc.