programing

wkhtmltopdf Docker 이미지 설치 및 실행 방법

css3 2023. 7. 24. 22:43

wkhtmltopdf Docker 이미지 설치 및 실행 방법

wkhtmltopdf를 설치하고 실행하고 싶습니다.DockerfileSpring-Boot애플리케이션을 구축하고 실행할 때Spring-boot어플.아래 주어진 스크립트를 작성했습니다.Dockerfilewkhtmltopdf를 설치합니다.

FROM debian:jessie

RUN apt-get update \
    && apt-get install -y \
        curl \
        libxrender1 \
        libfontconfig \
        libxtst6 \
        xz-utils

RUN curl "https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz" -L -o "wkhtmltopdf.tar.xz"
RUN tar Jxvf wkhtmltopdf.tar.xz
RUN mv wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf

ENTRYPOINT ["wkhtmltopdf"]

위의 스크립트는 도커 이미지를 생성했지만, wkhtmltopdf가 작동하는지 테스트하기 위해 이러한 이미지를 실행하는 방법은 무엇입니까?또는 wkhtmltopdf에서 설치하고 실행해야 하는 다른 접근 방식Dockerfile?

또 다른 간단한 대답:

# Create image based on the official openjdk 8-jre-alpine image from the dockerhub
FROM openjdk:8-jre-alpine

# Install wkhtmltopdf
RUN apk add --no-cache wkhtmltopdf

ENTRYPOINT ["wkhtmltopdf"]

아마도 이 솔루션이 도움이 될 것입니다.Wkhtmltopdf가 /usr/bin/wkhtmltopdf에 설치됩니다.

RUN apt-get update \
    && apt-get install -y \
    ...
    wkhtmltopdf \
    ...
# (Multi stage Docker can be considered. The appropriate Gradle cache use remains to be solved)

# Create image based on the official openjdk 11-jre-slim image from the dockerhub
FROM debian:jessie

ENV DIR=/usr/local/bin/

# Change directory so that our commands run inside this new directory
WORKDIR $DIR

ENV WKHTML_VERSION 0.12.4

# Builds the wkhtmltopdf download URL based on version number above
ENV DOWNLOAD_URL "https://downloads.wkhtmltopdf.org/0.12/${WKHTML_VERSION}/wkhtmltox-${WKHTML_VERSION}_linux-generic-amd64.tar.xz" -L -o "wkhtmltopdf.tar.xz"

# Install dependencies
RUN apt-get update && apt-get install -y \
    curl libxrender1 libfontconfig libxtst6 xz-utils

# Download and extract wkhtmltopdf
RUN curl $DOWNLOAD_URL
RUN tar Jxvf wkhtmltopdf.tar.xz
RUN cp wkhtmltox/bin/wkhtmltopdf $DIR

ENTRYPOINT ["wkhtmltopdf"]

언급URL : https://stackoverflow.com/questions/62589478/how-to-install-and-run-wkhtmltopdf-docker-image