PMFlow/mdproject/docker-machine-execution-pl...

60 lines
2.2 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.

# PMFlow Docker 机器级执行方案(本机 + 服务器)
## 1. 目标
- 统一本机运行入口,避免本地 `venv` 与 Docker 混用导致环境漂移。
- 固化 Docker 日常运维动作:启动、重启、状态、健康检查、日志查看。
- 固化跨服务器部署动作,支持最小人工步骤完成上线。
## 2. 当前基线(执行前)
- 项目目录:`/Users/yuuuu/Documents/AIProjectManger`
- 编排文件:`docker-compose.yml`
- 服务集合:`db` + `redis` + `backend` + `frontend`
- 容器映射端口:`5435` / `6379` / `8000` / `5174`
## 3. 执行任务
- [x] T1: 新增本地 Docker 运维脚本 `scripts/docker_stack.sh`
- [x] T2: 新增远程部署脚本 `scripts/deploy_remote_docker.sh`
- [x] T3: 新增部署说明 `docs/docker-server-deploy.md`
- [x] T4: 执行本机健康检查并记录结果
## 4. 执行命令(标准)
```bash
bash scripts/docker_stack.sh start
bash scripts/docker_stack.sh health
bash scripts/docker_stack.sh status
```
## 5. 服务器部署命令(标准)
```bash
bash scripts/deploy_remote_docker.sh <host> <user> </opt/pmflow>
```
## 6. 验收标准
- `docker compose ps` 中 4 个服务均为 `Up`,关键服务健康状态为 `healthy`。
- `http://127.0.0.1:8000/healthz` 返回成功。
- 运维脚本可重复执行,重入安全(多次执行不报错)。
- 远程部署脚本可完成:同步代码 -> 启动 compose -> 输出服务状态。
## 7. 回滚方案
- 停止容器:`bash scripts/docker_stack.sh stop`
- 恢复本地非 Docker 模式:执行项目原 `start.sh`
- 远程回滚:在目标机器执行 `docker compose down`,并切换到上一个代码版本
## 8. 执行回填
- [x] T1: done,新增 `scripts/docker_stack.sh`(支持 start/restart/stop/status/logs/health)
- [x] T2: done,新增 `scripts/deploy_remote_docker.sh`(支持 rsync + 远程 compose 部署)
- [x] T3: done,新增 `docs/docker-server-deploy.md`(部署与排障说明)
- [x] T4: done,本机执行通过:
- `bash scripts/docker_stack.sh start`
- `bash scripts/docker_stack.sh health`
- `bash scripts/docker_stack.sh status`
- `curl http://127.0.0.1:8000/healthz` 返回 `code=0`