refactor: .NET 镜像改为 build.sh 预下载 SDK/运行时,精简依赖并补充忽略文件
- compile/runtime dotnet6/8/9:ADD 本地 tar.gz 替代 ADD 远程 URL,压缩包由 build.sh 先下载(带缓存判断),避免构建时重复下载与层缓存失效 - 精简 yum 依赖:compile 镜像保留 gcc/make,runtime 镜像去掉编译工具链; 统一补装 libicu(.NET 全球化必需,缺失时 dotnet 命令直接 Abort) - 每个镜像目录新增 .dockerignore(不忽略 *.tar.gz,因需在构建上下文内)与 .gitignore - build.sh 加 shebang、set -euo pipefail,并 cd 到脚本所在目录,加可执行权限 - system-alinux3:设置时区软链,aliyun 镜像源域名修正为 mirrors.aliyun.com
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# 由 build.sh 预下载的运行时压缩包经 ADD 解压进镜像,
|
||||
# ADD 的源文件必须在构建上下文内,因此 *.tar.gz 不能在这里忽略
|
||||
build.sh
|
||||
.git/
|
||||
.DS_Store
|
||||
@@ -0,0 +1,3 @@
|
||||
# 构建产物 / 本地缓存
|
||||
*.tar.gz
|
||||
.DS_Store
|
||||
@@ -5,25 +5,12 @@ ENV DOTNET_HOME=/usr/local/dotnet
|
||||
ENV PATH="${DOTNET_HOME}:$PATH"
|
||||
WORKDIR /home/admin
|
||||
# https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-9.0.0-rc.2-linux-x64-binaries
|
||||
ADD https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/9.0.0-rc.2.24474.3/aspnetcore-runtime-9.0.0-rc.2.24474.3-linux-x64.tar.gz ./
|
||||
# 由 build.sh 预先下载到本目录
|
||||
ADD aspnetcore-runtime-9.0.0-rc.2.24474.3-linux-x64.tar.gz /usr/local/dotnet/
|
||||
# sysstat/net-tools 用于排障
|
||||
# libicu:.NET 全球化(CultureInfo/TimeZoneInfo)必需,缺了 dotnet 命令会直接 Abort
|
||||
RUN yum install \
|
||||
libffi-devel \
|
||||
zlib-devel \
|
||||
bzip2-devel \
|
||||
openssl-devel \
|
||||
ncurses-devel \
|
||||
sqlite-devel \
|
||||
readline-devel \
|
||||
tk-devel \
|
||||
gdbm-devel \
|
||||
libpcap-devel \
|
||||
xz-devel \
|
||||
make \
|
||||
patch \
|
||||
gcc \
|
||||
tar \
|
||||
libicu \
|
||||
sysstat \
|
||||
net-tools -y; \
|
||||
mkdir /usr/local/dotnet; \
|
||||
tar -xzvf aspnetcore-runtime-9.0.0-rc.2.24474.3-linux-x64.tar.gz -C /usr/local/dotnet; \
|
||||
dotnet --info;
|
||||
|
||||
Regular → Executable
+12
@@ -1,3 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# 先下载 aspnetcore-runtime 到当前目录,再基于本地文件构建镜像
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
RUNTIME=aspnetcore-runtime-9.0.0-rc.2.24474.3-linux-x64.tar.gz
|
||||
URL=https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/9.0.0-rc.2.24474.3/${RUNTIME}
|
||||
|
||||
if [ ! -f "${RUNTIME}" ]; then
|
||||
curl -fL -o "${RUNTIME}" "${URL}"
|
||||
fi
|
||||
|
||||
IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-dotnet9
|
||||
docker build -t "${IMAGE}" .
|
||||
docker push "${IMAGE}"
|
||||
|
||||
Reference in New Issue
Block a user