fix: 添加cargo清华镜像源,加速Hub本地构建

This commit is contained in:
fawney19
2026-03-02 03:04:56 +08:00
parent 039a18c243
commit 3eef673885
2 changed files with 8 additions and 1 deletions

View File

@@ -3,6 +3,13 @@
FROM rust:1.85-slim AS builder FROM rust:1.85-slim AS builder
WORKDIR /build/aether-hub WORKDIR /build/aether-hub
# 可选:配置国内 Cargo 镜像源(本地构建时传 --build-arg CARGO_MIRROR=1
ARG CARGO_MIRROR
RUN if [ -n "$CARGO_MIRROR" ]; then \
printf '[source.crates-io]\nreplace-with = "tuna"\n\n[source.tuna]\nregistry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"\n' \
> /usr/local/cargo/config.toml; \
fi
# 先构建依赖层,最大化后续代码变更时的缓存命中 # 先构建依赖层,最大化后续代码变更时的缓存命中
COPY Cargo.toml Cargo.lock ./ COPY Cargo.toml Cargo.lock ./
RUN mkdir src && printf 'fn main() {}\n' > src/main.rs RUN mkdir src && printf 'fn main() {}\n' > src/main.rs

View File

@@ -154,7 +154,7 @@ build_base() {
# 构建 Hub 镜像(本地) # 构建 Hub 镜像(本地)
build_hub() { build_hub() {
echo ">>> Building hub image (local)..." echo ">>> Building hub image (local)..."
docker build --pull=false -f aether-hub/Dockerfile -t aether-hub:local ./aether-hub docker build --pull=false --build-arg CARGO_MIRROR=1 -f aether-hub/Dockerfile -t aether-hub:local ./aether-hub
save_hub_hash save_hub_hash
} }