Add Docker deployment as the recommended production setup.

Include Dockerfile, docker-compose on port 3130, npm mirror config, deploy scripts, and DOCKER.md; keep PM2 docs as fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-10 21:13:12 +08:00
parent e44cdf913e
commit a1667eac51
10 changed files with 268 additions and 15 deletions
+34 -1
View File
@@ -1,7 +1,9 @@
# 知命阁(zhiminggeUbuntu 部署文档
# 知命阁(zhiminggeUbuntu 部署文档PM2 备选)
> 仓库:[https://git.bz121.com/dekun/zhimingge.git](https://git.bz121.com/dekun/zhimingge.git)
> **推荐改用 Docker 部署**,见 [DOCKER.md](./DOCKER.md)。本文档保留 PM2 手动部署说明。
本文档说明在 **Ubuntu 服务器**上使用 **root 用户**、**PM2** 将知命阁部署到 **`/opt/zhimingge`** 的完整流程。
---
@@ -391,6 +393,37 @@ pm2 logs zhimingge --lines 100
| 构建 OOM | 内存不足 | 增加 swap 或升级内存 |
| 流式输出中断 | Nginx 缓冲 | 设置 `proxy_buffering off` |
| Git pull 失败 | 凭据过期 | 重新配置 Token 或 SSH |
| `npm install` 长时间无输出 | 官方 npm 源慢 / 下载 `@next/swc` 等大包 | 见下方「npm 安装卡住」 |
### npm 安装卡住
国内服务器访问 `registry.npmjs.org` 常极慢,表现为 `npm install` 只有转圈、无进度。
**1. 先 Ctrl+C 中断,改用国内镜像:**
```bash
cd /opt/zhimingge
npm config set registry https://registry.npmmirror.com
npm config set fetch-timeout 600000
npm install --no-audit --no-fund --loglevel=info
```
项目根目录已包含 `.npmrc``git pull` 后自动生效),也可直接:
```bash
git pull origin main
npm install --loglevel=info
```
**2. 看卡在哪一步**(可选):
```bash
npm install --loglevel=verbose 2>&1 | tee /tmp/npm-install.log
```
若长时间停在 `@next/swc-*``sharp`,属正常现象,多等几分钟;超 10 分钟仍无进展再换镜像重试。
**3. 内存不足时**(构建阶段 OOM)见下方 Swap 配置。
### 构建内存不足时增加 Swap