如何在Docker php-fpm Alpine Linux上安装wkhtmltopdf?

qgelzfjb  于 2022-12-18  发布在  Docker
关注(0)|答案(1)|浏览(489)

我使用以下命令在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
falq053o

falq053o1#

从3.15版本https://pkgs.alpinelinux.org/packages?name=wkhtmltopdf&branch=edge&repo=&arch=&maintainer=开始,不能从alpine存储库安装wkhtmltopdf
如果你想在更新的alpine(3.17以下)中使用wkhtmltopdf,你可以从其他映像(如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.

字符串

相关问题