面向 Cursor Agent / 自动化改代码场景的工作镜像:预装 Node、Git、GitHub CLI、Cursor CLI(agent)和 graphify,可在容器内直接 clone、改代码、开 PR。
基础镜像:node:24
默认工作目录:/workspace
| 工具 | 说明 |
|---|---|
| Node.js 24 / npm | 前端与 JS 项目运行时 |
| git | 版本控制 |
| gh | GitHub CLI(PR / Issue / API) |
| openssh-client | git@github.com SSH 远程 |
| jq | 处理 gh JSON 输出 |
| Python 3 / uv | Python CLI 安装 |
| graphify | 代码知识图谱(已执行 graphify cursor install) |
Cursor CLI (agent) |
无头 Agent,读 CURSOR_API_KEY |
推送到 master 后由 GitHub Actions 构建并发布到 GHCR:
docker pull ghcr.io/kne-union/code-worker:latest标签:
latest— 最新master<short-sha>— 对应 commit
docker run --rm -it \
-e GH_TOKEN \
-e CURSOR_API_KEY \
-e GIT_AUTHOR_NAME="Your Name" \
-e GIT_AUTHOR_EMAIL="you@example.com" \
-v "$PWD:/workspace" \
ghcr.io/kne-union/code-worker:latest| 变量 | 用途 |
|---|---|
GH_TOKEN |
gh 鉴权;HTTPS git 也可配合该 token |
CURSOR_API_KEY |
Cursor Agent 鉴权(agent 会自动读取) |
GIT_AUTHOR_NAME / GIT_AUTHOR_EMAIL |
容器内 commit 身份 |
也可用 SSH(代替或补充 GH_TOKEN):
docker run --rm -it \
-v ~/.ssh:/root/.ssh:ro \
-v "$PWD:/workspace" \
-e CURSOR_API_KEY \
ghcr.io/kne-union/code-worker:latestgh repo clone owner/repo
cd repo
graphify update .
agent -p "fix the failing tests"
gh pr create --title "..." --body "..."docker build -t code-worker:dev .
docker run --rm -it -v "$PWD:/workspace" code-worker:dev- 不要把 token / SSH 私钥写进镜像,运行时通过
-e或挂载注入。 GH_TOKEN至少需要目标仓库的 Contents / Pull requests 等权限(按实际操作勾选)。- Cursor Agent 需要网络访问 Cursor API;受限网络或代理环境可能影响登录与索引。