chat/deployment/README.md

65 lines
1.5 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 Compose 部署說明
## 服務說明
### Redis
- 端口6379
- 用途:配對佇列、使用者狀態、房間成員管理
### Centrifugo
- HTTP API 端口8000
- WebSocket 端口8001
- 用途:即時訊息推送
- 配置文件:`centrifugo.json`
### Cassandra
- 端口9042
- 用途:聊天歷史訊息儲存
## 配置說明
### Centrifugo 配置
1. **更新 `centrifugo.json`**
- `token_hmac_secret_key`:必須與 `etc/chat-api.yaml` 中的 `JWT.CentrifugoSecret``JWT.Secret` 相同
- `api_key`:必須與 `etc/chat-api.yaml` 中的 `Centrifugo.APIKey` 相同
2. **範例配置**
```json
{
"token_hmac_secret_key": "your-secret-key-change-in-production",
"api_key": "api-key"
}
```
3. **對應的 `etc/chat-api.yaml`**
```yaml
Centrifugo:
APIURL: http://localhost:8000/api
APIKey: "api-key"
JWT:
Secret: "your-secret-key-change-in-production"
CentrifugoSecret: "" # 留空則使用 Secret
```
## 啟動服務
```bash
cd deployment
docker-compose up -d
```
## 驗證服務
- Redis: `redis-cli ping`
- Centrifugo: `curl http://localhost:8000/health`
- Cassandra: `docker exec -it cassandra cqlsh`
## 注意事項
1. **生產環境**:請務必修改所有預設密碼和 secret key
2. **Centrifugo Redis**:目前配置使用 Redis 作為 Centrifugo 的後端,確保 Redis 先啟動
3. **網路配置**:如果應用程序也在 Docker 中運行,請使用服務名稱(如 `centrifugo:8000`)而不是 `localhost`