fpanaccia / Wkhtmltopdf.NetCore.Example-deprecated

Implementation of Wkhtmltopdf.NetCore
81 stars 33 forks source link

Doesn't work in linux #6

Closed ghost closed 4 years ago

ghost commented 4 years ago

I have the exception after deploying in docker container(linux) System.IO.IOException: Broken pipe at Wkhtmltopdf.NetCore.GeneratePdf.GetByteArrayViewInHtml[T](String ViewInHtml, T model) at Document.API.Services.QuoteDocument.QuoteDocumentService.GenerateQuoteConfirmationDocument(QuoteConfirmationViewModel model) in /src/Services/Document/Document.API/Services/QuoteDocument/QuoteDocumentService.cs:line 28 at Document.API.Controllers.QuoteDocumentController.GetQuoteConfirmationDocument() in /src/Services/Document/Document.API/Controllers/QuoteDocumentController.cs:line 80 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) IMG: image

I guess that problem in Dockerfile (need to install extra packages) I changed Dockerfile(from example): `FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app RUN apt-get update -qq && apt-get -y install libgdiplus libc6-dev EXPOSE 80 EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["Services/Document/Document.API/Document.API.csproj", "Services/Document/Document.API/"] COPY ["BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj", "BuildingBlocks/EventBus/IntegrationEventLogEF/"] COPY ["BuildingBlocks/EventBus/EventBus/EventBus.csproj", "BuildingBlocks/EventBus/EventBus/"] COPY ["BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj", "BuildingBlocks/EventBus/EventBusRabbitMQ/"] COPY ["BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj", "BuildingBlocks/EventBus/EventBusServiceBus/"] RUN dotnet restore "Services/Document/Document.API/Document.API.csproj" COPY . . WORKDIR "/src/Services/Document/Document.API" RUN dotnet build "Document.API.csproj" -c Release -o /app/build

FROM build AS publish RUN dotnet publish "Document.API.csproj" -c Release -o /app/publish

FROM base AS final WORKDIR /app COPY --from=publish /app/publish . RUN chmod 755 /app/Rotativa/Linux/wkhtmltopdf

ENTRYPOINT ["dotnet", "Document.API.dll"]` IMG: image

Now I cannot build the image:

image

Can somebody help me to solve the problem?

fpanaccia commented 4 years ago

Hi, could you upload your solution?, if you cant, i will try to reproduce your case, but it seems a problem with that specific dockerfile

ghost commented 4 years ago

@fpanaccia Hi, thank you for answer. Problem was in linux (I am not good here, but after the time indicated in the error everything worked)

Now it works but I have another problem: inside linux container razor page didn't load bootstrap css file: image How it looks in windows: image

I am not sure that here problem with you library. I guess that minikube disable external connections.

ghost commented 4 years ago

I tested it from gcloud(gcloud has access to upload everything), also from local docker (in debug mode from vs2019). Seems linux version of wkhtmltopdf doesn't load css from cdn servers

ghost commented 4 years ago

The problem with downloading css file from cdn was the connection security: we cannot load file from https under http container. Everything else works fine.