feat: 新增 compile-rust 镜像(编译工具链 + 阿里云 crates 源)

This commit is contained in:
2026-11-15 11:17:50 +08:00
parent e8ae58e803
commit 159db44dad
4 changed files with 44 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
build.sh
.git/
.DS_Store
+4
View File
@@ -0,0 +1,4 @@
# 构建产物 / 本地缓存
*.tar.xz
*.sha256
.DS_Store
+29
View File
@@ -0,0 +1,29 @@
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-rust
LABEL MAINTAINER="tianjun@odboy.cn"
ENV TimeZone=Asia/Shanghai
# cargo 的 home 与缓存目录;运行时镜像不带 CARGO,编译镜像里保留即可
ENV CARGO_HOME=/home/admin/.cargo
ENV PATH="${CARGO_HOME}/bin:$PATH"
WORKDIR /home/admin
# gcc/make:链接 C 库与部分 build.rs;openssl-devel/pkg-config:reqwest 等依赖;
# gcc-c++ 供少部分含 C++ 的依赖;git:从 git 源拉依赖
RUN set -e && yum install \
gcc \
gcc-c++ \
make \
pkg-config \
openssl-devel \
ca-certificates \
git \
sysstat \
net-tools -y;
# crates 源换阿里云镜像(sparse 协议),避免直连 crates.io 超时;与 Python/Node 镜像用同一家源
RUN set -e && mkdir -p ${CARGO_HOME}; \
printf '%s\n' \
'[source.crates-io]' \
'replace-with = "aliyun"' \
'' \
'[source.aliyun]' \
'registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"' \
> ${CARGO_HOME}/config.toml; \
cargo -V
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# 编译镜像基于 runtime-rust:只需保证 runtime-rust 已构建,这里不再下载 Rust 发行包
set -euo pipefail
cd "$(dirname "$0")"
IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:compile-rust
docker build -t "${IMAGE}" .
docker push "${IMAGE}"