Skip to content

Instantly share code, notes, and snippets.

@migueloliveiradev
Created March 14, 2023 21:15
Show Gist options
  • Save migueloliveiradev/ea0ca7c61289c9f16c82fdcec13e2005 to your computer and use it in GitHub Desktop.
Save migueloliveiradev/ea0ca7c61289c9f16c82fdcec13e2005 to your computer and use it in GitHub Desktop.
Fixing System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build-env
WORKDIR /src
COPY ./WebApplication2/WebApplication2/* .
RUN dotnet restore
COPY ./WebApplication2/ .
RUN dotnet publish -c Release -o /publish
FROM mcr.microsoft.com/dotnet/aspnet:6.0 as runtime
#the libgdiplus download must be done in the aspnet runtime.
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install libgdiplus -y && \
apt-get clean -y
WORKDIR /publish
COPY --from=build-env /publish .
ENTRYPOINT ["dotnet", "WebApplication2.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment