docs(engineering): add project audit report and improvement plan

This commit introduces a comprehensive engineering audit report for the Tootaio Studio project. The report is structured into documents covering architecture, code quality, performance, security, CI/CD, and
observability. It also includes a phased improvement roadmap and a set of `.patch` files to apply immediate fixes for content schemas, package scripts, and CI configuration.
This commit is contained in:
xiaomai
2025-11-06 10:15:00 +08:00
parent 8cc04b7f59
commit 40b3ee147f
14 changed files with 744 additions and 0 deletions

40
docs/20251106/ci-cd.md Normal file
View File

@@ -0,0 +1,40 @@
# CI/CD 设计与部署方案
## 目标
提供从代码质量到产物构建的自动化流程lint → typecheck → build。
## GitHub Actions推荐
- 工作流文件参见补丁 `0003-github-actions-ci.patch`,关键步骤:
- 使用 `actions/setup-node@v4` + `corepack enable`
- 安装依赖:`pnpm i --frozen-lockfile`
- 执行 `pnpm lint && pnpm typecheck && pnpm build`
## 部署对比
- Vercel推荐
- 优点:零配置、内置 CDN、适配 Nuxt/NitroPreview 环境完善。
- 缺点:免费额度受限;对长时间 SSR 任务需商用套餐。
- Docker自管
- 优点:环境一致性高;更灵活接入内网服务。
- 缺点:需自建 CI/CD 与监控;维护成本更高。
- 自建 Node + Nginx
- 优点:成本可控;传统可见性强。
- 缺点:手工配置多;需要额外缓存/CDN 配合。
## Dockerfile示例
```dockerfile
FROM node:20-alpine AS build
WORKDIR /app
COPY . .
RUN corepack enable && pnpm i --frozen-lockfile && pnpm build
FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/.output ./.output
EXPOSE 3000
CMD ["node","./.output/server/index.mjs"]
```
## 环境变量与密钥
- 在 CI 中设置 `NITRO_PRESET``SENTRY_DSN`Nuxt 通过 `runtimeConfig` 注入,避免硬编码。