feat: 新增 runtime-rust 镜像(Rust 1.100.0,USTC 镜像站下载并校验 sha256)

This commit is contained in:
2026-11-15 11:05:31 +08:00
parent 0549686b65
commit d48cc7c451
4 changed files with 63 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# 由 build.sh 预下载的 Rust 发行包经 ADD 解压进镜像,
# ADD 的源文件必须在构建上下文内,因此 *.tar.xz 不能在这里忽略
build.sh
.git/
.DS_Store
+4
View File
@@ -0,0 +1,4 @@
# 构建产物 / 本地缓存
*.tar.xz
*.sha256
.DS_Store
+25
View File
@@ -0,0 +1,25 @@
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:system-alinux3
LABEL MAINTAINER="tianjun@odboy.cn"
ENV TimeZone=Asia/Shanghai
ENV RUST_HOME=/usr/local/rust
ENV PATH="${RUST_HOME}/bin:$PATH"
WORKDIR /home/admin
# https://mirrors.ustc.edu.cn/rust-static/dist/rust-1.100.0-x86_64-unknown-linux-gnu.tar.xz
# 由 build.sh 预先下载到本目录,并校验官方 .sha256
ADD rust-1.100.0-x86_64-unknown-linux-gnu.tar.xz /tmp/rust/
# install.sh 把 rustc/cargo 等装进 --prefix;glibc 运行时库 alinux3 自带
# 运行/编译镜像都不需要文档 rust-src rust-mingw 去掉可省下大半体积
RUN set -e && yum install \
gcc \
ca-certificates \
sysstat \
net-tools -y; \
cd /tmp/rust/rust-1.100.0-x86_64-unknown-linux-gnu; \
./install.sh \
--prefix=${RUST_HOME} \
--disable-ldconfig \
--without=rust-docs,rust-docs-json-preview,rustc-docs,rust-src,rust-mingw,rust-analysis; \
cd / && rm -rf /tmp/rust; \
chmod -R a+rx ${RUST_HOME}; \
rustc -V; \
cargo -V;
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# 先下载 Rust 官方发行包并校验官方 .sha256,再基于本地文件构建镜像
# compile-rust 复用本目录下载好的包(见 ../compile-rust/build.sh),因此这里也单独保留一份
set -euo pipefail
cd "$(dirname "$0")"
VERSION=1.100.0
TRIPLE=x86_64-unknown-linux-gnu
PKG=rust-${VERSION}-${TRIPLE}.tar.xz
URL=https://mirrors.ustc.edu.cn/rust-static/dist/${PKG}
# 镜像站不可达时的官方源
FALLBACK=https://static.rust-lang.org/dist/${PKG}
if [ ! -f "${PKG}" ]; then
curl -fL -o "${PKG}" "${URL}" || curl -fL -o "${PKG}" "${FALLBACK}"
fi
# 校验放在下载分支之外:包已存在时也校验;官方 .sha256 内容形如
# <hash> rust-<版本>-x86_64-unknown-linux-gnu.tar.xz
# 直接用它校验(文件名与包名一致,不需要改写);校验通过后不保留 .sha256
if [ ! -f "${PKG}.sha256" ]; then
curl -fL -o "${PKG}.sha256" "${URL}.sha256" || curl -fL -o "${PKG}.sha256" "${FALLBACK}.sha256"
fi
shasum -a 256 -c "${PKG}.sha256"
rm -f "${PKG}.sha256"
IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-rust
docker build -t "${IMAGE}" .
docker push "${IMAGE}"