Files
Mdeical_Sur_Report/docs/deployment.md
admin 2a86d9f5e4 Raise report upload request size limits
- Configure NestJS with an explicit JSON and urlencoded body parser limit controlled by API_BODY_LIMIT.

- Set the default API body limit to 100mb for report HTML, key frames, template images, and Data URL file uploads.

- Add a matching Nginx client_max_body_size 100m limit so Docker web proxy no longer rejects large report saves first.

- Document the new request body limit in README, deployment docs, progress notes, environment example, and AGENTS context.

- Rebuild and verify Docker web/api with a large report save through the Nginx /api proxy.
2026-05-02 03:29:46 +08:00

3.3 KiB
Raw Blame History

部署运行

如果是第一次安装项目,建议先阅读 安装与初始设置。本文档主要记录开发运行、质量检查、环境变量和 Docker/Nginx 部署边界。

本地开发

前端:

npm install
npm run dev

开发服务监听 0.0.0.0:3001。 开发模式下 Vite 会把 /api 代理到 VITE_API_PROXY_TARGET,默认 http://localhost:3100

后端:

cp .env.example .env
npm run prisma:generate
npm run server:dev

本地直接运行 API 默认监听 0.0.0.0:3100,健康检查为:

http://localhost:3100/api/health

如需连接真实 PostgreSQL

npm run prisma:migrate
npm run prisma:seed

质量检查

npm run lint
npm run test
npm run server:build
npm run build

当前 lint 实际执行 tsc --noEmit,用于 TypeScript 类型检查。

环境变量

复制示例文件:

cp .env.example .env.local

AI 和语音密钥由后端 Settings API 保存并由代理使用,前端不再注入 Gemini 旧环境变量。

后端新增变量:

  • API_PORTAPI 监听端口。本地直接运行默认 3100Docker Compose 暴露到宿主机的默认端口是 3002
  • API_BODY_LIMITAPI JSON/urlencoded 请求体上限,默认 100mb。报告正文、关键帧、模板图片和通用文件上传仍可能携带 Data URL调小会导致保存或上传出现 request entity too large
  • CORS_ORIGIN:允许跨域携带 Cookie 的前端来源。
  • DATABASE_URLPostgreSQL 连接串。Docker Compose 暴露到宿主机的默认端口是 5433,容器内部仍使用 db:5432
  • SESSION_SECRETSession Cookie 签名密钥。
  • SESSION_COOKIE_SECURE:是否只通过 HTTPS 发送 Session Cookie。本地 HTTP/Compose 默认 false,生产 HTTPS 应设为 true
  • FILE_STORAGE_DIR后端文件目录。Docker Compose 默认 /app/uploads,并挂载到 uploads_data volume。
  • VITE_API_PROXY_TARGET:前端开发服务器 /api 代理目标。直接运行后端用 http://localhost:3100;连接 Docker Compose API 用 http://localhost:3002
  • VITE_ENABLE_LOCAL_FALLBACK:生产构建是否允许本地兼容回退。开发模式默认启用,生产默认关闭。

Docker 部署

docker-compose up -d --build

默认通过 Nginx 暴露 http://localhost:4002

当前 Compose 服务:

  • web:前端静态站点,暴露 http://localhost:4002
  • apiNestJS API暴露 http://localhost:3002
  • dbPostgreSQL 16暴露 localhost:5433
  • uploads_data:后端文件持久化 volume。

构建流程:

  • Dockerfile 使用 Node 构建 dist/
  • 运行阶段使用 nginx:alpine 托管静态文件。
  • Dockerfile.server 构建并运行 NestJS API。
  • nginx.conf 已配置 SPA 路由回退、/api 反向代理和 100m 请求体上限。

部署边界

当前后端已承载登录认证、数据库 Session、Dashboard、报告、报告媒体关系、模板、字段库、通用文件/签名文件、视频/关键帧文件、用户管理、部门模板授权、系统设置、AI 代理、语音代理、HTML 清洗和审计日志查询。生产化前还需要补齐第三方代理调用摘要、限流、备份恢复、对象存储和更完整的旧数据迁移。