From bf452e3510085b3f6467a2f0fc992abbbcf3ce9a Mon Sep 17 00:00:00 2001 From: Xiaoxia AI Date: Tue, 23 Jun 2026 22:39:18 +0800 Subject: [PATCH] fix(ops): prune old docker artifacts after deploy --- docs/CURRENT-RELEASE-SURFACE.md | 6 +++--- docs/SAAS-UPGRADE-EXECUTION-CHECKLIST.md | 6 +++--- infra/docker/deploy-production.sh | 5 +++++ tests/unit/test_release_scripts.py | 8 ++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/CURRENT-RELEASE-SURFACE.md b/docs/CURRENT-RELEASE-SURFACE.md index e35abf660..1528a2f72 100644 --- a/docs/CURRENT-RELEASE-SURFACE.md +++ b/docs/CURRENT-RELEASE-SURFACE.md @@ -139,8 +139,8 @@ - 全局项目列表。 - 全局成员管理。 - 完整标题库。 -- 素材智能视图仍缺:高风险细分、未使用、真实最近使用回写。 -- 素材缺口诊断已开放基础版:准备度评分、推荐/慎用/未分类/最近上传/配音统计、生成前 critical 缺口拦截。 +- 素材智能视图仍缺:高风险细分、复核操作入口。 +- 素材缺口诊断已开放基础版:准备度评分、推荐/慎用/未分类/最近上传/未使用/已使用/待复核/配音统计、生成前 critical 缺口拦截。 - 成片历史管理、封面预览、批量下载、复核状态。 - 统一任务中心和任务重试。 - 模板编排和剪辑计划预览。 @@ -222,6 +222,6 @@ ## 7. 下一步 -1. 继续开发包 2 剩余项:素材使用次数/最近使用回写、复核状态、高风险细分。 +1. 继续开发包 2 剩余项:高风险细分、复核操作入口。 2. 执行真实浏览器 UAT:登录 → 工作空间 → 项目 → 批量上传 → 智能诊断 → 生成 → 下载。 3. 处理生产资源长期风险:升级生产机或迁移 Gitea。 diff --git a/docs/SAAS-UPGRADE-EXECUTION-CHECKLIST.md b/docs/SAAS-UPGRADE-EXECUTION-CHECKLIST.md index 7e09cd395..1bd191c82 100644 --- a/docs/SAAS-UPGRADE-EXECUTION-CHECKLIST.md +++ b/docs/SAAS-UPGRADE-EXECUTION-CHECKLIST.md @@ -110,8 +110,8 @@ - [x] 设计素材分类字段。 - [x] 设计风险分和质量分字段。 -- [ ] 设计使用次数和最近使用字段。 -- [ ] 设计复核状态字段。 +- [x] 设计使用次数和最近使用字段。 +- [x] 设计复核状态字段。 - [x] 增加分类 Worker 流程。 - [x] 增加智能视图 API。 - [x] 增加素材诊断 API。 @@ -124,7 +124,7 @@ - [x] 生产浏览器 E2E 验证上传诊断与生成下载。 - [x] 生产 API 负向 smoke 验证空视频库生成返回 422。 -当前生产基线:`v0.1.33`。剩余未完成:使用次数/最近使用、复核状态、素材使用回写。 +当前生产基线:`v0.1.36`。剩余未完成:高风险细分、复核操作入口。 验收:系统能回答“素材够不够、缺什么、哪些推荐、哪些慎用”。 diff --git a/infra/docker/deploy-production.sh b/infra/docker/deploy-production.sh index 83b00dda1..fabc73832 100755 --- a/infra/docker/deploy-production.sh +++ b/infra/docker/deploy-production.sh @@ -91,3 +91,8 @@ if [ -n "$RELEASE_VERSION" ] && [ -d "$HOST_PREFIX/etc/cron.d" ]; then */5 * * * * root cd /var/lib/xiaoxia-saas-production/repo && EXPECTED_VERSION=$RELEASE_VERSION sh scripts/production_resource_check.sh >/var/log/xiaoxia-resource-check.log 2>&1 EOF fi + +if [ "${PRUNE_UNUSED_DOCKER_AFTER_DEPLOY:-true}" = "true" ]; then + docker image prune -af --filter "until=168h" || true + docker builder prune -af --filter "until=168h" || true +fi diff --git a/tests/unit/test_release_scripts.py b/tests/unit/test_release_scripts.py index aa5bb06ad..a91a1455a 100644 --- a/tests/unit/test_release_scripts.py +++ b/tests/unit/test_release_scripts.py @@ -135,6 +135,14 @@ def test_deploy_scripts_build_web_image_explicitly(): assert "WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-1}" in compose +def test_production_deploy_prunes_old_unused_docker_artifacts(): + script = Path("infra/docker/deploy-production.sh").read_text(encoding="utf-8") + + assert "PRUNE_UNUSED_DOCKER_AFTER_DEPLOY" in script + assert "docker image prune -af --filter \"until=168h\"" in script + assert "docker builder prune -af --filter \"until=168h\"" in script + + def test_worker_runtime_is_constrained_by_environment(): dockerfile = Path("infra/docker/worker.Dockerfile").read_text(encoding="utf-8")