Add Docker deployment and CI/CD configuration
Some checks failed
Deploy to Production / deploy (push) Has been cancelled
Some checks failed
Deploy to Production / deploy (push) Has been cancelled
- Add Dockerfile for multi-stage build - Add docker-compose.yml for easy deployment - Add Gitea Actions CI/CD workflow - Add deployment script (deploy.sh) - Add nginx and supervisord configuration - Add deployment documentation Deployment target: 192.168.9.149:8080 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
190
DEPLOYMENT.md
Normal file
190
DEPLOYMENT.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# KT财务系统部署文档
|
||||
|
||||
## 🚀 快速部署
|
||||
|
||||
### 方式1:使用部署脚本(推荐)
|
||||
|
||||
```bash
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
### 方式2:使用Gitea Actions自动部署
|
||||
|
||||
推送代码到main分支后,Gitea Actions会自动触发部署。
|
||||
|
||||
## 📋 部署要求
|
||||
|
||||
### 服务器配置
|
||||
- **IP地址**: 192.168.9.149
|
||||
- **用户**: atai
|
||||
- **端口**: 22
|
||||
- **部署路径**: /home/atai/kt-financial-system
|
||||
- **访问地址**: http://192.168.9.149:8080
|
||||
|
||||
### 依赖环境
|
||||
- Docker
|
||||
- Docker Compose
|
||||
- Git
|
||||
|
||||
## 🛠️ 手动部署步骤
|
||||
|
||||
### 1. 安装sshpass(本地Mac)
|
||||
|
||||
```bash
|
||||
brew install hudochenkov/sshpass/sshpass
|
||||
```
|
||||
|
||||
### 2. 服务器初始化
|
||||
|
||||
SSH登录服务器:
|
||||
```bash
|
||||
ssh atai@192.168.9.149
|
||||
```
|
||||
|
||||
安装Docker:
|
||||
```bash
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
sudo usermod -aG docker $USER
|
||||
```
|
||||
|
||||
安装Docker Compose:
|
||||
```bash
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
```
|
||||
|
||||
### 3. 克隆代码
|
||||
|
||||
```bash
|
||||
cd /home/atai
|
||||
git clone https://gitea.ktyun.cc/chenjiangjiang/kt-financial-system.git
|
||||
cd kt-financial-system
|
||||
```
|
||||
|
||||
### 4. 启动服务
|
||||
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
### 5. 查看状态
|
||||
|
||||
```bash
|
||||
docker-compose ps
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
## 📝 常用命令
|
||||
|
||||
### 查看日志
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
### 重启服务
|
||||
```bash
|
||||
docker-compose restart
|
||||
```
|
||||
|
||||
### 停止服务
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### 重新构建
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
### 清理旧镜像
|
||||
```bash
|
||||
docker image prune -f
|
||||
```
|
||||
|
||||
## 🔧 配置说明
|
||||
|
||||
### 端口映射
|
||||
- **80** (容器内) → **8080** (宿主机)
|
||||
- 前端访问: http://192.168.9.149:8080
|
||||
- API访问: http://192.168.9.149:8080/api
|
||||
|
||||
### 环境变量
|
||||
在 `docker-compose.yml` 中配置:
|
||||
```yaml
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- TZ=Asia/Shanghai
|
||||
```
|
||||
|
||||
## 🐛 故障排查
|
||||
|
||||
### 容器无法启动
|
||||
```bash
|
||||
# 查看详细日志
|
||||
docker-compose logs
|
||||
|
||||
# 查看容器状态
|
||||
docker-compose ps
|
||||
|
||||
# 重新构建
|
||||
docker-compose up -d --build --force-recreate
|
||||
```
|
||||
|
||||
### 端口被占用
|
||||
```bash
|
||||
# 检查端口占用
|
||||
sudo netstat -tulpn | grep 8080
|
||||
|
||||
# 修改docker-compose.yml中的端口映射
|
||||
ports:
|
||||
- "8081:80" # 改为8081
|
||||
```
|
||||
|
||||
### 内存不足
|
||||
```bash
|
||||
# 清理Docker系统
|
||||
docker system prune -a
|
||||
|
||||
# 限制容器内存
|
||||
docker-compose.yml中添加:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 2G
|
||||
```
|
||||
|
||||
## 📊 监控
|
||||
|
||||
### 查看资源使用
|
||||
```bash
|
||||
docker stats kt-financial-system
|
||||
```
|
||||
|
||||
### 查看实时日志
|
||||
```bash
|
||||
docker-compose logs -f --tail=100
|
||||
```
|
||||
|
||||
## 🔄 更新部署
|
||||
|
||||
### 自动更新(Gitea Actions)
|
||||
推送代码到main分支即可自动部署
|
||||
|
||||
### 手动更新
|
||||
```bash
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
或:
|
||||
```bash
|
||||
ssh atai@192.168.9.149
|
||||
cd /home/atai/kt-financial-system
|
||||
git pull origin main
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
## 📞 技术支持
|
||||
|
||||
遇到问题请联系技术团队或查看:
|
||||
- Gitea: https://gitea.ktyun.cc/chenjiangjiang/kt-financial-system
|
||||
- Docker文档: https://docs.docker.com
|
||||
Reference in New Issue
Block a user