init
This commit is contained in:
59
DEPLOY.md
Normal file
59
DEPLOY.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# ChatRoom 部署说明
|
||||
|
||||
服务端口:**2779**
|
||||
|
||||
## 一、本地构建部署
|
||||
|
||||
```bash
|
||||
# 构建并启动(含 RabbitMQ)
|
||||
docker compose up -d --build
|
||||
|
||||
# 或使用部署脚本
|
||||
chmod +x deploy.sh
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
## 二、从镜像仓库部署(生产环境)
|
||||
|
||||
### 1. 构建并推送镜像
|
||||
|
||||
```bash
|
||||
# 构建
|
||||
docker build -t your-registry/chatroom:latest .
|
||||
|
||||
# 推送(示例:Docker Hub / 阿里云 ACR)
|
||||
docker push your-registry/chatroom:latest
|
||||
```
|
||||
|
||||
### 2. 服务器拉取并部署
|
||||
|
||||
```bash
|
||||
./deploy.sh your-registry/chatroom:latest
|
||||
```
|
||||
|
||||
## 三、自动更新部署
|
||||
|
||||
### 方式 A:Cron 定时拉取(推荐)
|
||||
|
||||
在服务器上添加 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
|
||||
```
|
||||
|
||||
### 方式 B:Watchtower 自动监控
|
||||
|
||||
```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
|
||||
- WebSocket:ws://服务器IP:2779/ws
|
||||
Reference in New Issue
Block a user