每次构建下载安装libgdiplus,导致构建非常慢。
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
COPY bin/Release/netcoreapp3.1 .
#System.Drawing.Common
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
RUN apt-get update -y && apt-get install -y libgdiplus locales fontconfig && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
ENTRYPOINT ["dotnet", "xxx.dll"]
制作一个带libgdiplus的基础镜像,Dockerfile ↓
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main contrib non-free
deb http://mirrors.aliyun.com/debian/ buster-updates main contrib non-free
deb http://mirrors.aliyun.com/debian/ buster-backports main contrib non-free
deb http://mirrors.aliyun.com/debian-security buster/updates main contrib non-free
" > /etc/apt/sources.list
RUN apt-get update -y && apt-get install -y libgdiplus locales fontconfig && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
构建镜像aspnet:3.1-buster-slim-gdi
docker build -f Dockerfile路径 -t mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim-gdi .