构建docker映像asp.net核心时出现OutofMemory异常

时间:2019-06-12 16:04:04

标签: docker asp.net-core gitlab

在构建基于asp.net核心的docker映像时,我会定期遇到以下异常

/usr/share/dotnet/sdk/2.2.300/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :  [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]
/usr/share/dotnet/sdk/2.2.300/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Unhandled Exception: OutOfMemoryException. [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]

Docker文件

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 12201
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["OrchestratorReverseProxy/OrchestratorReverseProxy.csproj", "OrchestratorReverseProxy/"]
RUN dotnet restore "OrchestratorReverseProxy/OrchestratorReverseProxy.csproj" /p:EnableDefaultItems=false
COPY . .
WORKDIR "/src/OrchestratorReverseProxy"
RUN dotnet build "OrchestratorReverseProxy.csproj" -c Release -o /app

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "OrchestratorReverseProxy.dll"]

构建日志

 Restore completed in 395.8 ms for /src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj.
/usr/share/dotnet/sdk/2.1.700/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :  [/src/OrchestratorReverseProxy/OrchestratorReverseProxy.csproj]
/usr/share/dotnet/sdk/2.1.700/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.CodeAnalysis.CSharp.Symbols.ExtraAnnotations' threw an exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. 

0 个答案:

没有答案