Surnet / docker-wkhtmltopdf

wkhtmltopdf for multiple base images
https://hub.docker.com/u/surnet/
MIT License
360 stars 65 forks source link

Help to build a docker image for net core apps #49

Closed fjsosa closed 5 months ago

fjsosa commented 5 months ago

Hi, I was trying to build a docker image based in this one to run a dotnet web app and I succesfully failed!. My question is: Is it possible to build an docker image that have preinstalled wkhtmltopdf?, or at least all the libraries required by wkhtmltopdf. My idea is to take that as base and add the net runtime an my binaries. Any help is welcomed! Thank you so much in advance.

chdanielmueller commented 5 months ago

Hi @fjsosa

Please try with this sample as a starting point:

FROM surnet/alpine-wkhtmltopdf:3.19.0-0.12.6-full as wkhtmltopdf
FROM mcr.microsoft.com/dotnet/aspnet:7.0.17-alpine3.19

# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
    libstdc++ \
    libx11 \
    libxrender \
    libxext \
    libssl3 \
    ca-certificates \
    fontconfig \
    freetype \
    ttf-dejavu \
    ttf-droid \
    ttf-freefont \
    ttf-liberation \
    # more fonts
  && apk add --no-cache --virtual .build-deps \
    msttcorefonts-installer \
  # Install microsoft fonts
  && update-ms-fonts \
  && fc-cache -f \
  # Clean up when done
  && rm -rf /tmp/* \
  && apk del .build-deps

# Copy wkhtmltopdf files from docker-wkhtmltopdf image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
COPY --from=wkhtmltopdf /bin/wkhtmltoimage /bin/wkhtmltoimage
COPY --from=wkhtmltopdf /bin/libwkhtmltox* /bin/