。NET Core + Docker Alpine + JsReport Local:没有这样的文件或目录

问题描述 投票:1回答:1

[我正在尝试在Docker Alpine映像上使用.NET Core运行JsReport。

我认为问题与该“ hack”有关”>

https://jsreport.net/learn/dotnet-local#docker

有人可以帮我翻译成Alpine命令吗?

按照我当前的配置和堆栈跟踪。

Startup.cs

services.AddJsReport(new LocalReporting()
                    .UseBinary(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
                                        jsreport.Binary.JsReportBinary.GetBinary() :
                                        jsreport.Binary.Linux.JsReportBinary.GetBinary())
                    .KillRunningJsReportProcesses()
                    .AsUtility()
                    .Create());

控制器

[HttpGet("generate/{uid}"), Route("generate")]
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult GenerateReport([FromQuery] Guid uid)
{
   ReportResponseModel model = _reportHelper.Get(uid);

   HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf)
   .Configure(c => c.Template.Chrome = new Chrome
   {
      Landscape = model.Landscape
   });

   return View(model.ViewName, model.ViewModel);
}

Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN apk add --update tzdata
ENV TZ=America/Sao_Paulo
WORKDIR /app
EXPOSE 80
EXPOSE 443

Stacktrace

System.ComponentModel.Win32Exception (2): No such file or directory
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at jsreport.Local.Internal.BinaryProcess.InnerExecute(String cmd, Boolean waitForExit)
at jsreport.Local.Internal.BinaryProcess.ExecuteExe(String cmd, Boolean waitForExit)
at jsreport.Local.Internal.LocalUtilityReportingService.RenderAsync(String requestString, CancellationToken ct)
at jsreport.AspNetCore.JsReportMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
 End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

[我正在尝试在Docker Alpine映像上使用.NET Core运行JsReport。我认为问题与该“ hack”有关:https://jsreport.net/learn/dotnet-local#docker有人可以帮我翻译...

docker .net-core alpine jsreport
1个回答
0
投票

问题是jsreport.Binary.Linux持有jsreport binary,而该文件未在高山上编译。也许只是缺少一些导致No such file or directory的依赖项,但我无法找出哪个依赖项。可能需要在alpine上重新编译二进制文件并将其嵌入到另一个jsreport.Binary.Linux.Alpine nuget中。

© www.soinside.com 2019 - 2024. All rights reserved.