Files
tootaio.com/docs/20251106/ci-cd.md
xiaomai 40b3ee147f 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.
2025-11-06 10:15:00 +08:00

41 lines
1.3 KiB
Markdown
Raw 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.
# 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` 注入,避免硬编码。