【问题标题】:wkhtmltopdf giving error inside the docker containerwkhtmltopdf 在 docker 容器内给出错误
【发布时间】:2021-06-20 19:49:46
【问题描述】:

我的 docker 容器中出现以下错误:

如何更新我的 dockerfile,以便在构建容器时使用带有修补 Qt 的 wkhtmltopdf 版本构建容器。

以下是我的 dockerfile:

...
RUN apt-get install -y wkhtmltopdf
RUN apt-get install -y xvfb

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
...

【问题讨论】:

    标签: docker docker-compose dockerfile pdf-generation wkhtmltopdf


    【解决方案1】:
    FROM php:7.4-fpm
    # Install dependencies, libssl1.1-dev ?
    RUN apt-get update && apt-get install -y \
        xvfb \
        wget \
        openssl \
        xorg \
        libssl1.1 \
        build-essential \
        libpng-dev \
        libjpeg62-turbo-dev \
        libfreetype6-dev \
        locales \
        zip \
        jpegoptim optipng pngquant gifsicle \
        vim \
        unzip \
        git \
        curl \
        libzip-dev \
        dcmtk \
        nginx \
        supervisor
    RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    RUN tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    RUN cp wkhtmltox/bin/wkhtmlto* /usr/bin/
    # Clear cache
    RUN apt-get clean && rm -rf /var/lib/apt/lists/*
    COPY php.ini /usr/local/etc/php/php.ini
    
    # adjustments to php.ini base on the production version.
    
    # Install extensions and configure
    
    RUN docker-php-ext-configure gd --with-freetype --with-jpeg
    RUN docker-php-ext-configure zip
    RUN docker-php-ext-install pdo_mysql zip exif pcntl gd sockets
    
    
    # RUN sed -E -i -e 's/max_execution_time = 1200/max_execution_time = 120/' /etc/php.ini \
    #  && sed -E -i -e 's/memory_limit = 128M/memory_limit = 512M/' /etc/php.ini \
    #  && sed -E -i -e 's/post_max_size = 8M/post_max_size = 64M/' /etc/php.ini \
    #  && sed -E -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 64M/' /etc/php.ini
    
    # php artisan storage:link 
    # THAT NEEDS TO BE RUN FROM THE nginx-home/LaravelPortal/ directory to symlink the storage directory.  NEED to figure out how to do that.
    # sudo docker exec -it  orthanc-docker-dev_ris_php-fpm_1 /bin/bash
    COPY default.conf /etc/nginx/conf.d/default.conf
    COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
    COPY entrypoint.sh /
    ENTRYPOINT ["/bin/bash","/entrypoint.sh"]
    

    【讨论】:

    • 将此添加为适用于我的构建的答案。现在所有选项似乎都可用。
    【解决方案2】:

    使用 wkhtmltopdf 安装以下依赖项对我来说很有效:

    ...
    RUN apt-get update
    RUN apt-get install -y xvfb
    RUN apt-get install -y wget
    RUN apt-get install -y openssl build-essential xorg libssl1.0-dev
    RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    RUN tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    RUN cp wkhtmltox/bin/wkhtmlto* /usr/bin/
    ...
    

    【讨论】:

    • 我可能有类似的问题。使用 composer 包移动到 Docker 并在容器中使用 wkhtmltopdf。我正在使用这个包装器:github.com/barryvdh/laravel-snappy 和 /usr/bin 中的容器二进制文件。一切仍然有效,但分页功能(即添加页脚)不起作用,并且不支持某些配置选项。我只需要按照上面的概述构建 DockerFile 吗?
    • 这是来自我现有的 DockerFile: FROM php:7.4-fpm RUN apt-get update && apt-get install -y \ build-essential \ libpng-dev \ libjpeg62-turbo-dev \ libfreetype6- dev\locales\zip\jpegoptim optipng pngquant gifsicle\vim\unzip\git\curl\libzip-dev\dcmtk\wkhtmltopdf\nginx\supervisor
    • 甜,这似乎奏效了。附加我的 DockerFile 以构建 nginx php-fpm 容器,该容器是我较大项目的一部分。从那里运行一个 Laravel 应用程序。
    • 我在使用 libssl1.0-dev 时遇到错误,所以我改为 libssl1.1 。不确定是否必须是 -dev ?
    猜你喜欢
    • 2021-09-27
    • 1970-01-01
    • 2012-10-15
    • 2019-08-21
    • 1970-01-01
    • 2018-03-19
    • 2019-01-27
    • 1970-01-01
    • 2019-12-04
    相关资源
    最近更新 更多