Files
wsmud/README_DEPLOY.md
2026-05-26 16:50:34 +08:00

76 lines
1.8 KiB
Markdown
Raw Permalink 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.
# 部署说明Docker / 本地 / 反向代理)
本文档说明如何在服务器上运行本项目Node + Express + Vite 前端构建)。
环境变量(必需)
- WEB_PORT: 前端/HTTP 服务端口(示例 80
- WS_PORT: 后端 WebSocket 端口(示例 4000
- MD5_PREFIX: 项目内部使用的 MD5 前缀
- DESIV: DES IV字符串
- SESSION_SECRET: express-session 的 secret
快速开始Docker Compose
1. 在项目根(带有 docker-compose.yml 的目录)创建或修改 `.env`,填入必需变量。示例:
```
WEB_PORT=80
WS_PORT=4000
MD5_PREFIX=change_me
DESIV=change_me
SESSION_SECRET=change_me
```
2. 构建并启动
```bash
docker compose up --build -d
```
3. 检查日志
```bash
docker compose logs -f
```
本地开发
- 前端:在 `src/` 目录使用 Vite 开发服务器
- npm run dev
- 后端(静态 + API
- npm run web (启动 web.js
- npm run os (启动 main.js后台游戏服务
反向代理(使用 Nginx
示例 Nginx 配置(简化)
```
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
持久化与备份
- SQLite 数据文件位于 `data/` 目录(`database.db`),请确保卷挂载或定期备份。
- 日志目录在 `log/`
K8s / CI/CD
- Dockerfile 为多阶段,已将前端构建产物输出到 `www/`
- 在 CI 中请先运行 `npm ci``npm run build`,然后构建镜像并推送到镜像仓库。
常见问题
- 端口冲突:确认 `WEB_PORT` 与宿主机端口映射一致
- 权限问题:确保 `data/``log/` 可由容器写入host 的 umask/owner