关于dockerfile小笔记
最近几次的系统发布,发现越来越慢,在teamcity上面制作一个阿里云镜像长达半个小时以上。最近一次更离谱,竟然超一个小时。
这样的话,我终于不淡定了。查看镜像生成日志,时间浪费在这句,花了大部分时间在下载系统源包:
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
因为必须在centos安装GDI这个画图插件,这句是不能去掉的。
于是自然想到必须用国内的下载地址,在dockerfile上指定系统源包的下载链接:
echo "deb http://mirrors.163.com/debian/ stretch main non-free contrib" > /etc/apt/sources.list && \
echo "deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \
echo "deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \
echo "deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list && \
这样再运行 apt-get update && apt-get install -y apt-utils 就非常畅快了。
这个经历的小总结:不能太将就,该调整就得调整。