Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install and run wkhtmltopdf Docker image

I want to install and run wkhtmltopdf from Dockerfile of Spring-Boot application when I will build and run the Spring-boot application. I have written the below given scripts in Dockerfile to install wkhtmltopdf.

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"]

The above scripts created a docker images, but how to run those images to test wkhtmltopdf is working or not? Or Any other approach we have to install & run wkhtmltopdf from Dockerfile?

like image 336
Vinaykumar Devarkond Avatar asked Jun 26 '20 06:06

Vinaykumar Devarkond


2 Answers

Another simple answer:

# 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"]
like image 127
Vinaykumar Devarkond Avatar answered Sep 21 '22 09:09

Vinaykumar Devarkond


Perhaps this solution will help. Wkhtmltopdf will be install to /usr/bin/wkhtmltopdf

RUN apt-get update \
    && apt-get install -y \
    ...
    wkhtmltopdf \
    ...
like image 23
Ivantsov Oleg Avatar answered Sep 19 '22 09:09

Ivantsov Oleg