【发布时间】:2020-03-23 14:34:56
【问题描述】:
当我创建一个用于部署的 docker 文件时,该应用程序通常在开发环境中工作,它因 libgdiplus 问题而失败。
DockerFile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
RUN apt-get update && apt-get install -y apt-utils
RUN apt-get install -y libfontconfig1
RUN apt-get install -y libgdiplus
RUN apt-get install -y libc6-dev
RUN ln -s /usr/lib/libgdiplus.so/usr/lib/gdiplus.dll
# copy csproj and restore as distinct layers
WORKDIR /src
COPY HelloWorld/HelloWorld.csproj HelloWorld/
RUN dotnet restore HelloWorld/HelloWorld.csproj
COPY . .
WORKDIR /src/HelloWorld
RUN dotnet build HelloWorld.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish HelloWorld.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "HelloWorld.dll"]
即使我尝试了以下脚本来加载库,但仍然失败
RUN apt-get update \
&& apt-get install -y --allow-unauthenticated \
libc6-dev \
libgdiplus \
libx11-dev \
&& rm -rf /var/lib/apt/lists/*
错误
Connection id "0HLRJJEGNBH3R", Request id "0HLRJJEGNBH3R:00000001": An unhandled exception was thrown by the application.
Aspose.Slides.PptxReadException: The type initializer for 'Gdip' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
【问题讨论】:
-
RUN ln -s /usr/lib/libgdiplus.so/usr/lib/gdiplus.dll,真的是你用的吗? -
@LexLi 删除此行后,我仍然遇到同样的问题。实际上我想加载这个库 RUN apt-get install -y libgdiplus。它已加载但错误仍然相同
-
该行只是问题的一部分。您仍然错过了一些东西,docs.aspose.com/display/pdfnet/… 无论如何,您需要供应商的支持才能获得确切的设置先决条件。
-
@LexLi 是否同样适用于 .NET 3.0?
-
@LexLi 感谢分享链接。现在我将字体复制到应用程序文件夹。 Aspose.Pdf.Text.FontRepository.Sources.Add(new Aspose.Pdf.Text.FolderFontSource(Path.GetFullPath(Directory.GetCurrentDirectory() + "//fonts//")));但它仍在搜索'/usr/share/fonts/truetype/msttcorefonts'
标签: asp.net docker dockerfile aspose