安装apt-get 安装 libc6-dev , libgdiplus 用于支持system.drawing 组件绘制,默认ubuntu命令
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
此方式每次构建都会重新install,因为镜像源的问题会很慢(最多30多分钟左右,偶尔还失败),每次项目构建发布该方式导致构建需要30多分钟实在让人无法接受。
配置apt的资源,采用阿里云资源仓库 必须是debian 10 buster版本
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib" >/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
这个时候在构建的时候就很快了。
完整dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
#FROM mcr.microsoft.com/dotnet/core/sdk:3.1
#安装apt-get 安装 libc6-dev , libgdiplus 用于支持system.drawing 组件绘制,默认ubuntu命令
#RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# 配置apt的资源,采用阿里云资源仓库 必须是debian 10 buster版本
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib" >/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
WORKDIR api
#项目设置里面将所有需要输出的xml文件输出到同一个doc目录下面
ADD ./bin/Release/netcoreapp3.1/publish/ /api/
ENTRYPOINT ["dotnet","/api/xxx.api.dll","--environment","Debug"]