- Dockerfile (Node/Python/Go/Bun + claude-code + gh cli)
- docker-compose.yml (flexible REPOS_DIR, 7 mounts, 6 cache volumes)
- CLAUDE.md (team conventions + red lines + per-repo build/test cmds)
- .claude/settings.json (allow/deny permissions)
- Makefile + scripts/{enter,bootstrap,run-task}.sh
- README.md (onboarding guide)
3.8 KiB
ai-ops —— 六仓库企业矩阵的 Agent 工作站
给 chat-gw / xiaoshou / gongdan / casdoor-internal / CloudCostbrank / lobechat-enterprise
这六个仓库提供一个开箱即用的 Claude Code 容器化工作环境。
每个团队成员在自己的机器上跑自己的容器,用自己的 Claude Max/Pro 订阅登录。 共享的只是这份仓库里的 Dockerfile / CLAUDE.md / settings.json。
前置条件
- macOS / Linux,装好 Docker Desktop(>= 4.30)并能拉公网镜像
- 有 Claude Max 或 Pro 订阅(或 Anthropic API Key)
- 能访问 6 个业务仓库的 GitHub 权限(已配好 ssh-key 或 gh auth login)
快速上手(3 分钟)
# 1. clone 本仓库(ai-ops)到你想放的地方,例如 ~/work
cd ~/work
git clone git@github.com:your-org/ai-ops.git
cd ai-ops
# 2. 一键初始化:clone 6 个业务仓库 + 构建镜像
make bootstrap
# 3. 进容器并登录
make enter
# 容器内:
/login # 浏览器完成 Claude Max/Pro 授权
/status # 确认登录成功
完成后,容器里 /workspace 下能看到 7 个目录(6 个业务仓库 + ai-ops 本身)。
目录约定
默认布局(REPOS_DIR 不设时):
~/work/ ← 任意名字
├── ai-ops/ ← 本仓库
├── chat-gw/
├── xiaoshou/
├── gongdan/
├── casdoor-internal/
├── CloudCostbrank/
└── lobechat-enterprise/
如果你 6 个仓库放在别处,编辑 .env:
REPOS_DIR=/Users/alice/projects
然后 make build && make enter 即可。
常用命令
make enter # 交互进入 Agent
make task CMD="扫描 6 仓库的 CVE 并提 PR" # 非交互单任务
make logout # 清除登录状态
make build # 重新构建镜像(改了 Dockerfile 后)
权限模型
- 容器内的 Agent 按
.claude/settings.json的 allow/deny 列表行事:- ✅ 允许:git 操作、
pytest/npm test/make/gh pr - ❌ 拒绝:
git push --force、rm -rf /、读.env、alembic downgrade、生产数据库操作
- ✅ 允许:git 操作、
- 你宿主机的
~/.ssh和~/.gitconfig只读挂载到容器内,git push 能用,但 Agent 改不了你本机配置 - 登录凭证存在 docker volume
claude-home,不要把这个 volume 导出给队友——每人各自/login自己的订阅
改团队规范(CLAUDE.md / settings.json)
这两个文件是全队共享的 Agent 行为约束:
CLAUDE.md—— 告诉 Agent 每个仓库是做什么的、该怎么测、红线在哪.claude/settings.json—— allow/deny 权限清单
改动流程:提 PR 到本仓库(ai-ops),团队 review 合并。每人下次 make build && make enter 就同步到本地。
出问题排查
Docker pull 失败 / TLS 证书错误 —— 检查是否有 VPN / 代理在做 HTTPS 拦截(例如 Astrill 的 OpenWeb 模式)。换成 WireGuard / StealthVPN,或关闭 VPN 后再拉镜像。
apt 装包失败
—— Dockerfile 已配清华镜像 + 重试 8 次。如果仍失败,检查网络对 mirrors.tuna.tsinghua.edu.cn 的访问。
/login 后仍提示未登录
—— 确认你的 Claude 订阅类型是 Max 或 Pro。Free 账号没有 Claude Code 权限。
想切到 API Key 模式
—— 编辑 .env,填 ANTHROPIC_API_KEY=sk-ant-...。API Key 优先级高于订阅。
不做什么
- 不是一个跑在云上的服务,不支持 SSH 远程访问
- 不是给 CI/CD 用的(CI 场景另用
.github/workflows/claude-review.yml+ API Key) - 不共享登录凭证 —— 每人用自己的订阅,违反 Claude TOS 会被踢
许可 / 归属
内部工具,仅限团队使用。六个业务仓库的许可证以各自仓库为准。