fix(deploy): --skip-build 模式自动重启容器 + commit 校验降级
## 问题 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 <noreply@anthropic.com>
This commit is contained in:
parent
12c1732617
commit
69100c3f40
@ -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,8 +138,15 @@ if [[ "$REMOTE_VERSION" != "$VERSION" ]]; then
|
||||
die "version mismatch! local=$VERSION remote=$REMOTE_VERSION (stale image?)"
|
||||
fi
|
||||
if [[ "$REMOTE_COMMIT" != "$COMMIT" && "$COMMIT" != "no-git" ]]; then
|
||||
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"
|
||||
log "open http://192.168.8.145:8001 to verify"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user