gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:18:13 24 4
gpt4 key购买 nike

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

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

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

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

遵循我当前的配置和stacktrace。

启动文件

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);
}

Docker文件
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


堆栈跟踪
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)

最佳答案

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

您是否可以考虑在另一个容器中运行完整的jsreport并使用例如docker-compose将容器链接在一起。这是一个演示
https://github.com/jsreport/jsreport-dotnet-example-docker-compose

关于docker - .NET Core + Docker Alpine + JsReport Local:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61962590/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com