rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 417 forks source link

Docker Linux Container (Debain) - invalid ELF header #121

Open imahruf opened 4 years ago

imahruf commented 4 years ago

Hi

I am getting below error message, anyone knows how to resolve it? I've read other threads but no luck.

System.DllNotFoundException: Unable to load shared library '/app/libwkhtmltox.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: /app/libwkhtmltox.dll: invalid ELF header
   at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath)

Below is my Dockerfile,

FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY ./ABC/ABC.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY ./ABC/. ./
RUN dotnet publish ABC.csproj -c Release -o out

# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .

# <wkhtmltopdf>

ENV PATH=/app;$PATH
RUN apt-get update
RUN apt-get install wget libgdiplus fontconfig libfreetype6 libx11-6 libxcb1 libxext6 libxrender1 xfonts-75dpi xfonts-base libjpeg62-turbo -y

RUN wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u12_amd64.deb
RUN dpkg -i libssl1.0.0_1.0.1t-1+deb8u12_amd64.deb

RUN wget http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_amd64.deb
RUN dpkg -i libpng12-0_1.2.50-2+deb8u3_amd64.deb

RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.jessie_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.jessie_amd64.deb

RUN wget -P /app https://github.com/rdvojmoc/DinkToPdf/raw/master/v0.12.4/64%20bit/libwkhtmltox.so
RUN wget -P /app https://github.com/rdvojmoc/DinkToPdf/raw/master/v0.12.4/64%20bit/libwkhtmltox.dll
RUN wget -P /app https://github.com/rdvojmoc/DinkToPdf/raw/master/v0.12.4/64%20bit/libwkhtmltox.dylib

RUN mkdir -p "/app/wkhtmltox/v0.12.4/64 bit" && cp libwkhtmltox.so "/app/wkhtmltox/v0.12.4/64 bit"
RUN mkdir -p "/app/wkhtmltox/v0.12.4/64 bit" && cp libwkhtmltox.dll "/app/wkhtmltox/v0.12.4/64 bit"
RUN mkdir -p "/app/wkhtmltox/v0.12.4/64 bit" && cp libwkhtmltox.dylib "/app/wkhtmltox/v0.12.4/64 bit"

RUN cp /usr/local/bin/wkhtmlto* /usr/bin/

RUN rm -rf *.deb

# </wkhtmltopdf>

EXPOSE 8080

ENTRYPOINT ["dotnet", "ABC.dll"]
eliseumade commented 1 year ago

managed to solve?