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.
This commit is contained in:
+4
-1
@@ -55,7 +55,10 @@ RUN git config --system --add safe.directory '*' \
|
|||||||
&& git config --system pull.rebase false \
|
&& git config --system pull.rebase false \
|
||||||
&& git config --system init.defaultBranch main
|
&& git config --system init.defaultBranch main
|
||||||
|
|
||||||
|
COPY scripts/container-entrypoint.sh /usr/local/bin/container-entrypoint.sh
|
||||||
|
RUN chmod +x /usr/local/bin/container-entrypoint.sh
|
||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/container-entrypoint.sh"]
|
||||||
CMD ["claude"]
|
CMD ["claude"]
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ services:
|
|||||||
GIT_COMMITTER_NAME: ${GIT_AUTHOR_NAME:-Claude Agent}
|
GIT_COMMITTER_NAME: ${GIT_AUTHOR_NAME:-Claude Agent}
|
||||||
GIT_COMMITTER_EMAIL: ${GIT_AUTHOR_EMAIL:-claude-agent@local}
|
GIT_COMMITTER_EMAIL: ${GIT_AUTHOR_EMAIL:-claude-agent@local}
|
||||||
TERM: xterm-256color
|
TERM: xterm-256color
|
||||||
|
# 传宿主 HOME 给 entrypoint,让 installed_plugins.json 里的绝对路径可解析
|
||||||
|
HOST_HOME: ${HOME}
|
||||||
volumes:
|
volumes:
|
||||||
# REPOS_DIR 默认指向 ai-ops 的父目录;队友可在 .env 里改成自己的工作目录
|
# REPOS_DIR 默认指向 ai-ops 的父目录;队友可在 .env 里改成自己的工作目录
|
||||||
- ${REPOS_DIR:-..}/chat-gw:/workspace/chat-gw
|
- ${REPOS_DIR:-..}/chat-gw:/workspace/chat-gw
|
||||||
@@ -35,6 +37,10 @@ services:
|
|||||||
- ./CLAUDE.md:/workspace/CLAUDE.md:ro
|
- ./CLAUDE.md:/workspace/CLAUDE.md:ro
|
||||||
- ./.claude:/workspace/.claude
|
- ./.claude:/workspace/.claude
|
||||||
- claude-home:/root/.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
|
- pip-cache:/root/.cache/pip
|
||||||
- go-cache:/root/go/pkg
|
- go-cache:/root/go/pkg
|
||||||
- npm-cache:/root/.npm
|
- npm-cache:/root/.npm
|
||||||
|
|||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 容器启动时运行的初始化脚本:
|
||||||
|
# 1) 如果 HOST_HOME 被传入且与 $HOME 不同,建立 symlink 让绝对路径兼容
|
||||||
|
# (例:宿主机 /Users/alice/.claude 里的 installed_plugins.json 含
|
||||||
|
# 绝对路径 /Users/alice/.claude/plugins/cache/... —— 需要容器里
|
||||||
|
# /Users/alice 也能解析到 /root,否则插件加载失败)
|
||||||
|
# 2) 最后 exec 真实命令
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ -n "${HOST_HOME:-}" && "$HOST_HOME" != "$HOME" && "$HOST_HOME" != "/" ]]; then
|
||||||
|
if [[ ! -e "$HOST_HOME" ]]; then
|
||||||
|
parent=$(dirname "$HOST_HOME")
|
||||||
|
mkdir -p "$parent"
|
||||||
|
ln -sfn "$HOME" "$HOST_HOME"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user