File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ RUNTIME_ROOT=/root/cross-subject-knowledge ./scripts/deploy_vps.sh
3013014 . 在 VPS 上先构建新镜像,再停旧容器,避免“构建失败直接打挂线上”。
3023025 . 新容器通过 ` /api/health ` 健康检查后才算部署成功;失败则自动回滚到上一镜像。
3033036 . 运行时模型缓存保存在宿主机 ` state/cache/ ` ,避免每次发版都把 Hugging Face 缓存烘进镜像。
304- 7 . 部署完成后自动清理悬空镜像,并只保留最近几份 ` pre-* ` 回滚镜像。
304+ 7 . 部署完成后自动清理悬空镜像,只保留最近几份 ` pre-* ` 回滚镜像,并删除历史 ` build-* ` tag 。
305305
306306### 3. 服务器 (VPS) 迁移指南
307307由于大头数据 (4GB+ 图片) 都在云端 CDN,如果未来需要更换服务器提供商,迁移将极其简单轻量:
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ Current production deploy is:
58584 . Host model cache is reused or warmed before cutover
59595 . Old container is replaced only after image build succeeds
60606 . ` /api/health ` must pass or the script rolls back to the previous image
61- 7 . Dangling images are pruned; only recent rollback tags are retained
61+ 7 . Dangling images are pruned; only recent rollback tags are retained and old ` build-* ` tags are removed
6262
6363## Operational watchpoints
6464
Original file line number Diff line number Diff line change @@ -136,6 +136,14 @@ if [ -n "${old_pre_tags}" ]; then
136136 done <<< " ${old_pre_tags}"
137137fi
138138
139+ old_build_tags=" $( docker images --format ' {{.Repository}}:{{.Tag}}' | grep ' ^textbook-knowledge:build-' | grep -v " ^${build_tag} $" || true) "
140+ if [ -n " ${old_build_tags} " ]; then
141+ while IFS= read -r image_ref; do
142+ [ -n " ${image_ref} " ] || continue
143+ docker rmi " ${image_ref} " > /dev/null 2>&1 || true
144+ done <<< " ${old_build_tags}"
145+ fi
146+
139147echo " === disk after deploy ==="
140148df -h /
141149docker system df
You can’t perform that action at this time.
0 commit comments