docs(deployment): 更新 sidebar 部署流程和容器重建说明
- 替换旧的更新 index.html 缓存戳逻辑为 docker-compose 方式重建镜像和容器 - 明确禁止使用 docker cp 更新 sidebar,避免容器重建时文件丢失 - 说明服务器 Dockerfile 直接复制 dist 和 nginx.conf,需先完成 scp 步骤 - 添加重启外层 nginx 容器以解析容器 IP 变化 - 增加自检步骤,验证三个入口页面标题是否正确返回及大小不相同
This commit is contained in:
parent
a9a762a761
commit
912c354dfb
39
AGENTS.md
39
AGENTS.md
@ -23,35 +23,20 @@ cd frontend/sidebar && npm run build
|
|||||||
# 2. 同步到服务器(注意带 JS hash 的文件名会变化)
|
# 2. 同步到服务器(注意带 JS hash 的文件名会变化)
|
||||||
scp -r -o StrictHostKeyChecking=no -i root.pem frontend/sidebar/dist/* root@8.133.162.25:/www/wwwroot/deploy-package/frontend/sidebar/dist/
|
scp -r -o StrictHostKeyChecking=no -i root.pem frontend/sidebar/dist/* root@8.133.162.25:/www/wwwroot/deploy-package/frontend/sidebar/dist/
|
||||||
|
|
||||||
# 3. SSH 登录服务器,更新 index.html 缓存戳并重启容器
|
# 3. SSH 登录服务器,重建镜像并重建容器(持久化,容器再被 recreate 也不会回滚)
|
||||||
|
# ⚠️ 禁止再用 docker cp 更新 sidebar:cp 进容器可写层的内容在容器 recreate 时会全部丢失
|
||||||
|
# (2026-09-03 容器被重建后回滚到 6 月旧镜像,summary-search/reminder 页面线上故障)
|
||||||
|
# ⚠️ 服务器 Dockerfile 直接 COPY 服务端 dist/ 与 nginx.conf,故必须先完成第 2 步 scp
|
||||||
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
|
ssh -o StrictHostKeyChecking=no -i root.pem root@8.133.162.25 << 'EOF'
|
||||||
cd /www/wwwroot/deploy-package/frontend/sidebar/dist
|
cd /www/wwwroot/deploy-package
|
||||||
# 更新 index.html 中的 JS/CSS 引用,带上版本戳防缓存
|
docker-compose build sidebar
|
||||||
JS_FILE=$(ls assets/index-*.js | head -1)
|
docker-compose up -d --no-deps sidebar
|
||||||
CSS_FILE=$(ls assets/index-*.css | head -1)
|
# 容器重建后 IP 变化,外层 nginx 需重启重新解析 DNS
|
||||||
cat > index.html << HTML
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
||||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
|
||||||
<title>AI坐席助手</title>
|
|
||||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
|
|
||||||
<script type="module" crossorigin src="/sidebar/$JS_FILE?v=$(date +%s)"></script>
|
|
||||||
<link rel="stylesheet" crossorigin href="/sidebar/$CSS_FILE?v=$(date +%s)">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
HTML
|
|
||||||
# 复制到容器并重启
|
|
||||||
docker cp . ai-assistant-sidebar:/usr/share/nginx/html/
|
|
||||||
# 若 frontend/sidebar/nginx.conf 有变更(如新增页面路由),需同步到容器再 reload
|
|
||||||
docker cp ../nginx.conf ai-assistant-sidebar:/etc/nginx/conf.d/default.conf
|
|
||||||
docker exec ai-assistant-sidebar nginx -t && docker exec ai-assistant-sidebar nginx -s reload
|
|
||||||
docker restart ai-assistant-nginx
|
docker restart ai-assistant-nginx
|
||||||
|
# 自检:三个入口应返回各自标题,且 size 互不相同
|
||||||
|
curl -sk https://ai.9artedu.com/sidebar/summary | grep -o '<title>[^<]*</title>'
|
||||||
|
curl -sk https://ai.9artedu.com/sidebar/summary-search | grep -o '<title>[^<]*</title>'
|
||||||
|
curl -sk https://ai.9artedu.com/sidebar/reminder | grep -o '<title>[^<]*</title>'
|
||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user