Files
ChatRoom/DEPLOY.md
2026-02-04 00:41:34 +08:00

61 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.
# ChatRoom 部署说明
服务端口:**2779**
## 一、本地构建部署
```bash
# 构建并启动(含 RabbitMQ
docker compose up -d --build
# 或使用部署脚本
chmod +x deploy.sh
./deploy.sh
```
## 二、从镜像仓库部署(生产环境)
### 1. 构建并推送镜像
```bash
# 构建
docker build -t zhengdushi/chatroom:latest .
# 推送示例Docker Hub / 阿里云 ACR
docker push zhengdushi/chatroom:latest
```
### 2. 服务器拉取并部署
```bash
cd /chatroom
docker compose pull app && docker compose up -d
```
## 三、自动更新部署
### 方式 ACron 定时拉取(推荐)
在服务器上添加 crontab每 5 分钟检查并更新:
```bash
crontab -e
# 添加(替换为你的镜像地址)
*/5 * * * * cd /path/to/ChatRoom && CHATROOM_IMAGE=your-registry/chatroom:latest docker compose pull app && docker compose up -d --no-build
```
### 方式 BWatchtower 自动监控
```bash
# 先设置环境变量
export CHATROOM_IMAGE=your-registry/chatroom:latest
# 启动应用 + Watchtower每 5 分钟检查镜像更新)
docker compose -f docker-compose.yml -f docker-compose.watchtower.yml --profile watchtower up -d
```
## 四、访问地址
- 前端页面http://服务器IP:2779
- WebSocketws://服务器IP:2779/ws