下面是一套**固定、完整、推荐的 Docker 启动流程**。以后就按这套来,不要再单独用本地 `python` 或 `pnpm dev` 启动。 工作目录统一为: ```powershell cd D:\work\code\python\coding\baodanagent ``` --- ## 1. 启动 Docker Desktop 如果 Docker Desktop 没启动,先手动打开 Docker Desktop,或者用命令启动: ```powershell Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe" ``` 等待 Docker 就绪: ```powershell docker info ``` 如果能正常输出 `Server` 信息,说明 Docker 已经启动成功。 --- ## 2. 可选:清理本地误启动的开发进程 如果之前误用过本地 `python -m insurance.app` 或 `pnpm dev`,可能会占用 `5001`、`5173` 端口。 执行下面命令清理本地占用: ```powershell $ports = 5001,5173 $ownerIds = Get-NetTCPConnection -LocalPort $ports -ErrorAction SilentlyContinue | Where-Object { $_.State -eq 'Listen' } | Select-Object -ExpandProperty OwningProcess -Unique foreach ($ownerId in $ownerIds) { if ($ownerId -and $ownerId -ne $PID) { Stop-Process -Id $ownerId -Force -ErrorAction SilentlyContinue Write-Output "Stopped local process $ownerId" } } ``` 注意:Docker 部署实际不会用 `5173`,`5173` 是本地 Vite 开发端口。 --- ## 3. 启动 BaoDan / Dify 全量后端服务 根目录执行: ```powershell docker compose -f docker-compose.dify.yml up -d ``` 这一步会启动: - PostgreSQL - Redis - BaoDan API - BaoDan Web 管理端 - Worker - Plugin Daemon - Sandbox --- ## 4. 启动保险自研前端 继续在根目录执行: ```powershell docker compose -f docker-compose.frontend.yml up -d ``` 这一步会启动保险自研 Vue 前端。 --- ## 5. 如果只是重启,不重新构建 日常服务打不开时,优先使用: ```powershell docker compose -f docker-compose.dify.yml restart docker compose -f docker-compose.frontend.yml restart ``` --- ## 6. 如果改了代码,需要重新构建并启动 如果改了后端、前端代码,建议用下面命令重建。 ### 重建 BaoDan / Dify 服务 ```powershell docker compose -f docker-compose.dify.yml up -d --build ``` ### 重建保险前端 ```powershell docker compose -f docker-compose.frontend.yml up -d --build ``` --- ## 7. 查看容器状态 ```powershell docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" ``` 正常情况下应该能看到类似这些容器: ```text baodanagent-baodanagent-web-1 Up ... 0.0.0.0:9080->8080/tcp baodanagent-baodan-api-1 Up ... 0.0.0.0:5001->5001/tcp baodanagent-baodan-web-1 Up ... 0.0.0.0:3000->3000/tcp baodanagent-baodan-worker-1 Up ... baodanagent-plugin_daemon-1 Up ... 0.0.0.0:5002-5003->5002-5003/tcp baodanagent-db-1 Up ... 0.0.0.0:5433->5432/tcp baodanagent-redis-1 Up ... 0.0.0.0:6380->6379/tcp baodanagent-sandbox-1 Up ... ``` --- ## 8. 当前固定访问地址 ### 保险自研前端 浏览器打开: ```text http://localhost:9080/ ``` 局域网访问: ```text http://192.168.1.17:9080/ ``` --- ### BaoDan / Dify 管理后台 浏览器打开: ```text http://localhost:3000/ ``` 或者: ```text http://localhost:3000/apps ``` 局域网访问: ```text http://192.168.1.17:3000/ ``` --- ### 后端 API ```text http://localhost:5001 ``` 局域网访问: ```text http://192.168.1.17:5001 ``` 健康检查: ```text http://localhost:5001/health ``` 当前验证返回正常: ```json {"pid":84,"status":"ok","version":"1.14.2"} ``` --- ## 9. 关键接口验证命令 ### 检查保险前端 ```powershell curl.exe -I --max-time 15 http://localhost:9080/ ``` 正常应返回: ```text HTTP/1.0 200 OK ``` --- ### 检查 BaoDan 管理后台 ```powershell curl.exe -I --max-time 15 http://localhost:3000/apps ``` 正常应返回: ```text HTTP/1.1 200 OK ``` --- ### 检查后端健康状态 ```powershell curl.exe --max-time 15 http://localhost:5001/health ``` 正常应返回: ```json {"pid":84,"status":"ok","version":"1.14.2"} ``` --- ### 检查保险智能体接口 ```powershell curl.exe --max-time 15 http://localhost:5001/insurance/agents/list ``` 当前已经验证成功,返回了智能体列表,例如: ```json { "code": 0, "data": [ { "name": "保险智能客服", "mode": "chat" } ] } ``` --- ## 10. 查看日志 ### 查看 BaoDan API 日志 ```powershell docker logs -f baodanagent-baodan-api-1 ``` ### 查看保险前端日志 ```powershell docker logs -f baodanagent-baodanagent-web-1 ``` ### 查看 BaoDan 管理端日志 ```powershell docker logs -f baodanagent-baodan-web-1 ``` ### 查看 Worker 日志 ```powershell docker logs -f baodanagent-baodan-worker-1 ``` ### 查看数据库日志 ```powershell docker logs -f baodanagent-db-1 ``` --- ## 11. 停止服务 如果只是停止,不删除数据: ```powershell docker compose -f docker-compose.frontend.yml down docker compose -f docker-compose.dify.yml down ``` --- ## 12. 不建议执行的命令 除非你明确知道后果,否则不要执行下面这种带 `-v` 的命令: ```powershell docker compose -f docker-compose.dify.yml down -v ``` 因为 `-v` 会删除数据库、Redis 等 Docker volume,可能导致数据丢失。 --- ## 13. 最终推荐的一键启动顺序 以后最常用就是这一套: ```powershell cd D:\work\code\python\coding\baodanagent docker info docker compose -f docker-compose.dify.yml up -d docker compose -f docker-compose.frontend.yml up -d docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" curl.exe --max-time 15 http://localhost:5001/health curl.exe -I --max-time 15 http://localhost:9080/ curl.exe -I --max-time 15 http://localhost:3000/apps ``` --- ## 14. 最终固定地址汇总 | 服务 | 地址 | |---|---| | 保险自研前端 | `http://localhost:9080/` | | BaoDan / Dify 管理后台 | `http://localhost:3000/` | | BaoDan / Dify Apps 页面 | `http://localhost:3000/apps` | | 后端 API | `http://localhost:5001` | | 后端健康检查 | `http://localhost:5001/health` | | 智能体列表接口 | `http://localhost:5001/insurance/agents/list` | | PostgreSQL | `localhost:5433` | | Redis | `localhost:6380` | | Plugin Daemon | `localhost:5002` | | Plugin Remote Install | `localhost:5003` |