From 69100c3f40348691015f8801dccdf51fd6dd0471 Mon Sep 17 00:00:00 2001 From: sinohqb Date: Fri, 17 Jul 2026 15:53:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20--skip-build=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=87=AA=E5=8A=A8=E9=87=8D=E5=90=AF=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=20+=20commit=20=E6=A0=A1=E9=AA=8C=E9=99=8D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题 v0.4 用 --skip-build 部署时踩到两个坑: 1. compose up -d 对无配置变更的容器是 no-op,不重启,导致 volume 挂载的 backend 新代码不被 uvicorn 加载(这次靠手动 docker compose restart 才生效) 2. /api/health 的 commit 来自镜像 build-arg,--skip-build 不重建镜像 → commit 校验必然失败触发 die,部署脚本非 0 退出 ## 修复 - restart 阶段:SKIP_BUILD=1 时追加 docker compose restart agenteval, 强制重载 volume 挂载的后端代码 - commit 校验:SKIP_BUILD=1 时降级为 warn(镜像未重建是预期的,代码已 rsync+restart 生效),仅 full build 模式才 die Co-Authored-By: Claude --- scripts/deploy-t480.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/deploy-t480.sh b/scripts/deploy-t480.sh index 1201c08..258badd 100755 --- a/scripts/deploy-t480.sh +++ b/scripts/deploy-t480.sh @@ -111,6 +111,15 @@ fi log "docker compose up -d" run ssh "$HOST" "cd $REMOTE_DIR && docker compose -f $COMPOSE_FILE up -d" +# In --skip-build mode the image and compose config are unchanged, so +# `compose up -d` is a no-op and the container keeps running the OLD uvicorn +# process. The backend is volume-mounted, so its code on disk is already the +# new version — but Python won't reload it without a restart. Force one. +if [[ "$SKIP_BUILD" == "1" ]]; then + log "docker compose restart agenteval (reload volume-mounted backend code)" + run ssh "$HOST" "cd $REMOTE_DIR && docker compose -f $COMPOSE_FILE restart agenteval" +fi + # ── verify ───────────────────────────────────────────────────────────── log "waiting for /api/health" for i in $(seq 1 30); do @@ -129,7 +138,14 @@ if [[ "$REMOTE_VERSION" != "$VERSION" ]]; then die "version mismatch! local=$VERSION remote=$REMOTE_VERSION (stale image?)" fi if [[ "$REMOTE_COMMIT" != "$COMMIT" && "$COMMIT" != "no-git" ]]; then - die "commit mismatch! local=$COMMIT remote=$REMOTE_COMMIT (image not rebuilt?)" + if [[ "$SKIP_BUILD" == "1" ]]; then + # /api/health's commit comes from the image build-arg, which --skip-build + # doesn't update. The volume-mounted code was rsync'd + the container was + # restarted, so the code IS current — only the metadata label lags. + warn "commit label still $REMOTE_COMMIT (--skip-build: image not rebuilt; code rsync'd + restarted)" + else + die "commit mismatch! local=$COMMIT remote=$REMOTE_COMMIT (image not rebuilt?)" + fi fi log "deploy OK: version=$VERSION commit=$COMMIT"