Files
xmwork/docker-compose.yml
gongzhiyong ab2ea0730e fix(plugins): expose host Claude plugins + skills to container
Root cause of '容器里看不到任何 SK':
- Container's /root/.claude was an isolated named volume (empty)
- Host plugins live in ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/
- installed_plugins.json embeds ABSOLUTE paths like /Users/$USER/.claude/...
  which don't resolve in container

Fix:
1. docker-compose.yml
   - Bind-mount ${HOME}/.claude/plugins -> /root/.claude/plugins (ro)
   - Bind-mount ${HOME}/.claude/skills  -> /root/.claude/skills  (ro)
   - Pass HOST_HOME env var
2. scripts/container-entrypoint.sh (new)
   - If HOST_HOME != HOME, symlink HOST_HOME -> /root so the absolute
     paths inside installed_plugins.json resolve (e.g.
     /Users/gongzhiyong/.claude/... -> /root/.claude/...)
3. Dockerfile
   - Install entrypoint, wire it into ENTRYPOINT via tini

Verified: all 4 installed plugins (oh-my-claudecode, superpowers,
frontend-design, planning-with-files) + 3 skills (agent-browser,
find-skills, omc-reference) visible in container.
2026-04-24 23:16:14 +08:00

69 lines
2.6 KiB
YAML

name: ai-ops
services:
claude-agent:
build:
context: .
dockerfile: Dockerfile
image: claude-agent-6repos:latest
container_name: claude-agent
hostname: claude-agent
stdin_open: true
tty: true
working_dir: /workspace
environment:
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
ANTHROPIC_MODEL: ${ANTHROPIC_MODEL:-claude-opus-4-7}
CLAUDE_CODE_USE_BEDROCK: ${CLAUDE_CODE_USE_BEDROCK:-}
AWS_REGION: ${AWS_REGION:-}
AWS_PROFILE: ${AWS_PROFILE:-}
GH_TOKEN: ${GH_TOKEN:-}
GITHUB_TOKEN: ${GH_TOKEN:-}
GIT_AUTHOR_NAME: ${GIT_AUTHOR_NAME:-Claude Agent}
GIT_AUTHOR_EMAIL: ${GIT_AUTHOR_EMAIL:-claude-agent@local}
GIT_COMMITTER_NAME: ${GIT_AUTHOR_NAME:-Claude Agent}
GIT_COMMITTER_EMAIL: ${GIT_AUTHOR_EMAIL:-claude-agent@local}
TERM: xterm-256color
# 传宿主 HOME 给 entrypoint,让 installed_plugins.json 里的绝对路径可解析
HOST_HOME: ${HOME}
volumes:
# REPOS_DIR 默认指向 ai-ops 的父目录;队友可在 .env 里改成自己的工作目录
- ${REPOS_DIR:-..}/chat-gw:/workspace/chat-gw
- ${REPOS_DIR:-..}/xiaoshou:/workspace/xiaoshou
- ${REPOS_DIR:-..}/gongdan:/workspace/gongdan
- ${REPOS_DIR:-..}/casdoor-internal:/workspace/casdoor-internal
- ${REPOS_DIR:-..}/CloudCostbrank:/workspace/CloudCostbrank
- ${REPOS_DIR:-..}/lobechat-enterprise:/workspace/lobechat-enterprise
- ./CLAUDE.md:/workspace/CLAUDE.md:ro
- ./.claude:/workspace/.claude
- claude-home:/root/.claude
# 共享宿主 Claude Code 的 plugins + skills(只读)
# 让容器里的 claude 能看到 superpowers / oh-my-claudecode / frontend-design 等
- ${HOME}/.claude/plugins:/root/.claude/plugins:ro
- ${HOME}/.claude/skills:/root/.claude/skills:ro
- pip-cache:/root/.cache/pip
- go-cache:/root/go/pkg
- npm-cache:/root/.npm
- pnpm-store:/root/.local/share/pnpm/store
- bun-cache:/root/.bun/install/cache
- ${HOME}/.ssh:/root/.ssh:ro
# az CLI / gh CLI 需要写 session cache,不能用 :ro
- ${HOME}/.azure:/root/.azure
- ${HOME}/.config/gh:/root/.config/gh
# 注意:不要挂载 ~/.gitconfig —— 若宿主机没这个文件,Docker 会
# 把它自动创建为「空目录」,导致 git 报错。用上面 GIT_AUTHOR_*
# 环境变量就足够了。
healthcheck:
test: ["CMD", "claude", "--version"]
interval: 30s
timeout: 10s
retries: 3
volumes:
claude-home:
pip-cache:
go-cache:
npm-cache:
pnpm-store:
bun-cache: