Commit Graph
8 Commits
Author SHA1 Message Date
zhangxiang 722f08a159 fix(deploy): 上传前生成 nginx web root 镜像,并把部署验证升级为资源级断言
2026-10-08 生产事故:deploy.sh 打出「🎉 部署成功」而线上 CSS/JS/图标全 404。
根因是 nginx 站点根就是上传后的 dist/(nginx-static-production.conf:132 的
root /var/www/novalon + :136-142 的 try_files $uri =404),要求磁盘上存在
dist/_next/static/**;而 next build 出的是 dist/static/**,postbuild 只补
standalone 容器形态。历史镜像由旧流程产出,被本次 rsync --delete 抹掉。

- 步骤 1.5:上传前本地生成镜像(dist/static → dist/_next/static、public/. → dist/),
  dist/static 缺失即终止部署而非静默继续
- verify_remote:从首页 HTML 实际引用的 URL 取前 5 个 /_next/static/*.{js,css}
  加 /favicon.ico 逐个断言 200,任一非 200 即 return 1。负对照实测:换成不存在
  的取样 URL ⇒ RED 404 且 failed=1,断言可失败
- 只查五个 HTML 路径的门禁,在破站状态下会判绿——这是本次事故的直接放大原因
2026-10-08 17:41:35 +08:00
zhangxiang d4caa7bef3 fix(deploy): 修复生产 CMS 解密失败与媒体库 500
- deploy.sh 构建时从 .env.production 显式注入 NEXT_PUBLIC_ENCRYPTION_SECRET,
  避免 .env.local 开发密钥覆盖生产密钥,导致前端 chunk 与后端 ENCRYPTION_SECRET
  不匹配,CMS 所有列表/仪表盘解密失败(The operation failed for an
  operation-specific reason)
- Dockerfile.prod 新增 sharp-deps 阶段,为 Alpine 容器补充 @img/sharp-linuxmusl-x64
  平台依赖,修复媒体库接口缺失 musl 二进制导致的 500
2026-08-20 12:06:34 +08:00
zhangxiang f14b82ab63 fix(deploy): wait for Next.js container readiness before verification
The container can still be booting when Nginx starts proxying, causing a
temporary 502 in the post-deploy verification. Poll localhost:3000 for up
to 60s after recreating the container.
2026-08-18 13:11:11 +08:00
zhangxiang f815f87e3d fix(deploy): brace COMPOSE_FILE in Chinese echo string
Bash treated the full-width comma after $COMPOSE_FILE as part of the
variable name under UTF-8 locale, causing an unbound variable error at
the Next.js container rebuild step.
2026-08-18 13:09:23 +08:00
zhangxiang c06309b2f2 feat(deploy): rebuild Next.js container after dist upload
Hybrid rendering requires the Next.js runtime to use the same build as
the client assets served by Nginx. After uploading dist, sync public/
to the server project and rebuild/restart the novalon-website container
so server action IDs and /_next/static references stay consistent.
2026-08-18 13:06:52 +08:00
zhangxiang 57e00aa4b4 fix(deploy): serve standalone client chunks at /_next/static
Next.js standalone output places client chunks under dist/static, but the
generated HTML references /_next/static/... which Nginx serves from
dist/_next/static. Mirror static -> _next/static during build so CSS/JS
load with correct MIME types instead of 404.
2026-08-18 13:03:58 +08:00
zhangxiang 6fa5e4bf32 fix(deploy): sync public assets into standalone dist root
Next.js standalone output does not place public/ files at the dist root,
so rsync --delete was removing logo/favicon/fonts/images from production.
Copy public/ into dist after build so Nginx can serve them.
2026-08-18 12:56:19 +08:00
zhangxiang af57504e8e refactor(deploy): 统一发布脚本为单一入口 scripts/deploy.sh
- 新增 scripts/deploy.sh,支持 build/deploy/rollback/status 子命令
- 删除 deploy.sh、deploy-dist.sh、scripts/deploy-static.sh、scripts/deployment/deploy-production.sh
- Jenkinsfile 部署/回滚改为调用统一脚本,移除内联部署逻辑与 STATIC_DIR
- 同步 README、DEPLOYMENT、docs、CLAUDE.md、setup-cicd 与 package.json 脚本
2026-08-17 18:40:51 +08:00