Complete Docker compose deployment setup

- Add an API container entrypoint that waits for PostgreSQL, runs Prisma migrations, seeds demo data, and then starts NestJS.

- Keep Prisma CLI and seed dependencies available in the API runtime image and copy seed source dependencies into the container.

- Add Docker Compose healthchecks and health-based startup ordering for PostgreSQL, API, and Nginx web services.

- Add Docker initialization environment switches for migrations, seed, and startup retries.

- Add a dedicated Docker deployment guide covering services, ports, initialization, HTTPS, production variables, backup, restore, and troubleshooting.

- Update README, AGENTS, installation, deployment, progress, and environment example docs for the Dockerized workflow.
This commit is contained in:
2026-05-02 05:38:03 +08:00
parent 2cabe7e4fd
commit 5d936832da
12 changed files with 269 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
# 部署运行
如果是第一次安装项目,建议先阅读 [安装与初始设置](./installation.md)。本文档主要记录开发运行、质量检查、环境变量和 Docker/Nginx 部署边界。
如果是第一次安装项目,建议先阅读 [安装与初始设置](./installation.md)。Docker Compose 的完整一键部署、健康检查、初始化脚本和生产变量见 [Docker 化部署](./docker.md)。本文档主要记录开发运行、质量检查、环境变量和 Docker/Nginx 部署边界。
## 本地开发
@@ -65,6 +65,9 @@ AI 和语音密钥由后端 Settings API 保存并由代理使用,前端不再
- `SESSION_SECRET`Session Cookie 签名密钥。
- `SESSION_COOKIE_SECURE`:是否只通过 HTTPS 发送 Session Cookie。本地 HTTP/Compose 默认 `false`,生产 HTTPS 应设为 `true`
- `FILE_STORAGE_DIR`后端文件目录。Docker Compose 默认 `/app/uploads`,并挂载到 `uploads_data` volume。
- `RUN_DB_MIGRATIONS`Docker API 容器启动时是否执行 `prisma migrate deploy`,默认 `true`
- `RUN_DB_SEED`Docker API 容器启动时是否执行 `prisma db seed`,默认 `true`
- `DOCKER_STARTUP_RETRIES` / `DOCKER_STARTUP_RETRY_DELAY`Docker API 启动脚本等待数据库、migration 和 seed 的重试次数与间隔。
- `VITE_API_PROXY_TARGET`:前端开发服务器 `/api` 代理目标。直接运行后端用 `http://localhost:3100`;连接 Docker Compose API 用 `http://localhost:3002`
- `VITE_ENABLE_LOCAL_FALLBACK`:生产构建是否允许本地兼容回退。开发模式默认启用,生产默认关闭。
@@ -83,6 +86,8 @@ docker-compose up -d --build
- `db`PostgreSQL 16暴露 `localhost:5433`
- `uploads_data`:后端文件持久化 volume。
`api` 容器启动时默认会等待数据库健康,执行 `prisma migrate deploy``prisma db seed`,再启动 NestJS API。可通过 `RUN_DB_MIGRATIONS``RUN_DB_SEED` 关闭自动初始化。
构建流程:
- `Dockerfile` 使用 Node 构建 `dist/`
@@ -90,6 +95,8 @@ docker-compose up -d --build
- `Dockerfile.server` 构建并运行 NestJS API。
- `nginx.conf` 已配置 SPA 路由回退、`/api` 反向代理、`100m` 请求体上限和自签名 HTTPS 演示入口。
更完整的 Docker 说明、生产变量、证书和备份恢复见 [Docker 化部署](./docker.md)。
## 麦克风访问
浏览器不允许普通局域网 HTTP 页面调用麦克风代码无法绕过这个限制。Docker 演示环境建议使用: