Files
3970260761 0d3a714438 移除左侧AI创作面板「AI视频生成/AI图片生成」两个页签
- 删除 AiMain 中对应 TabPane 及 AiVideo/AiImage 组件,保留一键出片与生成结果
- 生图/生视频仍走 AI 助手对话的图片/视频生成模式,引导文案不变
- 修复 AiMain 被误删的 Button/QuickVideo/useState 引用(面板渲染即崩)
- 修复 build.sh/docs 硬编码旧源码路径 /vol1 → /vol3(仓库迁移残留)
- build.sh 构建改走 DOCKER_BUILDKIT=0 legacy 构建器,规避 docker.io DNS 污染
- 验证:线上页签仅剩一键出片/生成结果,页面断言4/4,bundle 残留0;README/CHANGELOG 已更新
2026-11-11 00:38:18 +08:00

82 lines
2.9 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
#
# UniCut 站点构建发布脚本(带断网 lint 门禁)
#
# bash scripts/build.sh
#
# 流程:拿构建锁 → 刷新本地素材 → 构建镜像 → 发布容器 → 导出产物跑 lint → curl 健康检查
#
# 环境变量:
# SKIP_LOCALIZE=1 跳过素材下载(默认会跑 scripts/localize-assets.py,可重复执行、已存在则跳过)
# SKIP_LINT=1 跳过产物 lint(只做构建发布)
#
# 说明:构建锁放在 /tmp/unicut_build.lock,避免多个任务并发 build 互相覆盖镜像与容器;
# 构建日志统一写 /tmp/unicut_build_site.log。
set -euo pipefail
SRC=/vol3/1000/HD3/docker/unicut-src
LOCK=/tmp/unicut_build.lock
LOG=/tmp/unicut_build_site.log
SITE=https://127.0.0.1:3005
WAIT_MAX=${LOCK_WAIT_MAX:-600}
cd "$SRC"
# ---------- 1. 构建锁 ----------
waited=0
until mkdir "$LOCK" 2>/dev/null; do
if [ "$waited" -ge "$WAIT_MAX" ]; then
echo "[build] 等待构建锁超时($LOCK 已被占用 ${WAIT_MAX}s)" >&2
exit 1
fi
echo "[build] 构建锁被占用,${waited}s 后重试…"
sleep 15
waited=$((waited + 15))
done
trap 'rmdir "$LOCK" 2>/dev/null || true' EXIT
echo "[build] 拿到构建锁(等待了 ${waited}s)"
# ---------- 2. 本地素材(可重复执行) ----------
if [ "${SKIP_LOCALIZE:-0}" != "1" ]; then
echo "[build] 刷新本地素材 scripts/localize-assets.py"
python3 scripts/localize-assets.py || echo "[build] 素材刷新有失败项,继续构建(详见 data-quality/reports/site/assets-localize.json)"
fi
# ---------- 3. 构建 + 发布 ----------
echo "[build] docker compose build unicut(日志:$LOG)"
{
# docker.io DNS 污染环境:legacy 构建器直接用本地基础镜像,不向 docker.io 查元数据
DOCKER_BUILDKIT=0 docker compose build unicut
docker compose up -d --no-build unicut
} 2>&1 | tee "$LOG"
# ---------- 4. 导出产物并跑断网 lint ----------
if [ "${SKIP_LINT:-0}" != "1" ]; then
DIST=$(mktemp -d /tmp/unicut-dist-XXXXXX)
docker exec unicut tar -C /usr/share/nginx/html -cf - . | tar -C "$DIST" -xf -
echo "[build] 断网 lint:dist 导出到 $DIST"
set +e
python3 data-quality/scripts/site/00_lint_dist.py --dist "$DIST" 2>&1 | tee -a "$LOG"
LINT_RC=${PIPESTATUS[0]}
set -e
else
LINT_RC=0
fi
# ---------- 5. 健康检查:首页与详情页必须 200 ----------
echo "[build] 健康检查 $SITE"
for path in / /article/local-deploy-guide /article/offline-ready /offline-notice.html; do
code=$(curl -sk -o /dev/null -w '%{http_code}' "$SITE$path")
echo "[build] $code $SITE$path"
if [ "$code" != "200" ]; then
echo "[build] ❌ $path 返回 $code" >&2
exit 1
fi
done
if [ "$LINT_RC" -ne 0 ]; then
echo "[build] ❌ 断网 lint 未通过(external_refs != 0),详见上方报告" >&2
exit "$LINT_RC"
fi
echo "[build] ✅ 构建、发布、lint、健康检查全部通过"