ci(music): docker build --no-cache 主 image,根治 binary stale
deploy music / build-and-deploy (push) Successful in 1m44s
deploy music / build-and-deploy (push) Successful in 1m44s
之前 cargo build 有跑出新 musl binary 但 docker build 时 'Step 2/5 : COPY target/.../music — Using cache' 命中旧 layer, 把历史 binary 套进新 sha tag 的 image。结果 main.rs 改动悄悄丢失。 回退之前迂回的 cargo clean -p / rm binary(治不到 docker 那层), 直接给主 image 加 --no-cache。chord-fetcher 那个 sidecar 保留 cache(chromium apt 拉一次 200MB+,每次重 build 太慢)。
This commit is contained in:
@@ -31,15 +31,7 @@ jobs:
|
|||||||
- name: Build rust (musl static)
|
- name: Build rust (musl static)
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
export PATH="$HOME/.cargo/bin:$PATH"
|
||||||
# 强制 invalidate music crate 的 fingerprint —— act_runner workdir
|
|
||||||
# 复用导致 cargo 偶尔会"看不见"main.rs 修改,链不出新 binary。
|
|
||||||
# `cargo clean -p` 只清这一 crate,依赖 deps 的编译结果保留,重 link 大约 30-60s。
|
|
||||||
cargo clean -p "$APP" --release --target x86_64-unknown-linux-musl
|
|
||||||
rm -f "target/x86_64-unknown-linux-musl/release/$APP"
|
|
||||||
cargo build --release --target x86_64-unknown-linux-musl -p "$APP"
|
cargo build --release --target x86_64-unknown-linux-musl -p "$APP"
|
||||||
# 防御性检查:commit 字符串必须出现在 binary 里
|
|
||||||
SHA="${{ steps.tag.outputs.sha }}"
|
|
||||||
test -f "target/x86_64-unknown-linux-musl/release/$APP"
|
|
||||||
|
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: |
|
run: |
|
||||||
@@ -52,10 +44,13 @@ jobs:
|
|||||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo "$REGISTRY_TOKEN" | docker login registry.famzheng.me -u mochi --password-stdin
|
echo "$REGISTRY_TOKEN" | docker login registry.famzheng.me -u mochi --password-stdin
|
||||||
# main app
|
# main app —— 必须 --no-cache,否则 docker layer cache 会把"COPY target/.../music"
|
||||||
docker build -f "apps/$APP/Dockerfile" -t "$IMAGE:${{ steps.tag.outputs.sha }}" .
|
# 这一层套用历史 binary(之前几次 deploy 实测过:cargo 生成了新 binary 但
|
||||||
|
# docker 看缓存 layer 命中直接复用旧 binary,新代码完全没进 image)
|
||||||
|
docker build --no-cache -f "apps/$APP/Dockerfile" \
|
||||||
|
-t "$IMAGE:${{ steps.tag.outputs.sha }}" .
|
||||||
docker push "$IMAGE:${{ steps.tag.outputs.sha }}"
|
docker push "$IMAGE:${{ steps.tag.outputs.sha }}"
|
||||||
# chord-fetcher sidecar (python + chromium)
|
# chord-fetcher sidecar:layer cache 这里有用(chromium apt 不变),保留
|
||||||
docker build -f "apps/$APP/chord/Dockerfile" \
|
docker build -f "apps/$APP/chord/Dockerfile" \
|
||||||
-t "$CHORD_IMAGE:${{ steps.tag.outputs.sha }}" \
|
-t "$CHORD_IMAGE:${{ steps.tag.outputs.sha }}" \
|
||||||
"apps/$APP/chord"
|
"apps/$APP/chord"
|
||||||
|
|||||||
Reference in New Issue
Block a user