feat(devcontainer): add compose-based local devcontainer bootstrap#65
feat(devcontainer): add compose-based local devcontainer bootstrap#65
Conversation
- Move the devcontainer setup to docker-compose and generate a local override for host-specific mounts and environment. - Bootstrap shell history and optional host-matched CLI tools inside the container to make local development setup more reproducible.
Walkthrough开发容器配置从基于单一镜像的设置重构为 Docker Compose 驱动方案。新增四个引导脚本分别用于探测宿主工具、生成本地覆盖配置、启动全局包管理工具和配置 Shell 历史。Dockerfile 中添加了 Node.js 24 LTS 和 XDG 目录预创建。 Changes开发容器环境重构
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
.devcontainer/scripts/probe-host-tools.sh (1)
72-72: 💤 Low value可选:用双引号消除 ShellCheck SC2016 警告
此处
`是纯字面字符(用于 Markdown 风格代码展示),\n由printf正常解释——单引号版本功能上完全正确。ShellCheck SC2016 属于误报,但改用双引号可以明确意图并消除告警。♻️ 建议修改
-printf 'Tip: rerun `bash /workspaces/RMCS/.devcontainer/scripts/bootstrap-tools.sh` to resync container tool versions with the host.\n' +printf "Tip: rerun \`bash /workspaces/RMCS/.devcontainer/scripts/bootstrap-tools.sh\` to resync container tool versions with the host.\n"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.devcontainer/scripts/probe-host-tools.sh at line 72, The printf invocation that prints a tip uses single quotes which triggers ShellCheck SC2016; change the printf call that contains the literal backticks and \n (the printf 'Tip: rerun `bash /workspaces/RMCS/.devcontainer/scripts/bootstrap-tools.sh` to resync container tool versions with the host.\n' line) to use double quotes for the format string so the intent is explicit and the SC2016 warning is suppressed—keep the same text and escape sequences unchanged, only replace the surrounding quotes..devcontainer/docker-compose.yml (2)
3-3: 💤 Low value可选:固定镜像摘要以提高可复现性
latest-full是可变 tag,团队成员不同时间构建容器可能拉到不同镜像版本,导致环境不一致。若需强一致性,可改用@sha256:...摘要或带版本号的具体 tag。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.devcontainer/docker-compose.yml at line 3, The docker-compose image uses a floating tag "qzhhhi/rmcs-develop:latest-full" which can cause non-reproducible builds; update the image reference in .devcontainer/docker-compose.yml by replacing the floating tag with a pinned identifier—either a specific versioned tag (e.g., rmcs-develop:vX.Y.Z) or an immutable digest form "qzhhhi/rmcs-develop@sha256:..."—so that the service definition consistently pulls the exact same image.
13-15: 💤 Low value无头主机上
/tmp/.X11-unix不存在时 Docker 会自动创建空目录如果宿主机没有运行 X server(无头服务器、远程 SSH 无 X 转发),Docker 会在
/tmp/下创建一个空的.X11-unix目录,容器可以正常启动,但 X11 转发不可用。该行为对本地开发场景无影响,但若该环境同时在 CI/无头机器上使用,可参考generate-local-override.sh中[ -e "$host_path" ]的条件挂载模式,将此 mount 移入生成的 override 文件以实现按需挂载。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.devcontainer/docker-compose.yml around lines 13 - 15, The bind mount of /tmp/.X11-unix in docker-compose.yml causes Docker to create an empty directory on headless hosts; move this mount out of the main docker-compose.yml and into the generated override mechanism used by generate-local-override.sh so it is only added when the host path exists—follow the existing pattern in generate-local-override.sh (the [ -e "$host_path" ] conditional) to conditionally include the /tmp/.X11-unix bind mount for the service that currently lists source: /tmp/.X11-unix and target: /tmp/.X11-unix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.devcontainer/docker-compose.yml:
- Line 3: The docker-compose image uses a floating tag
"qzhhhi/rmcs-develop:latest-full" which can cause non-reproducible builds;
update the image reference in .devcontainer/docker-compose.yml by replacing the
floating tag with a pinned identifier—either a specific versioned tag (e.g.,
rmcs-develop:vX.Y.Z) or an immutable digest form
"qzhhhi/rmcs-develop@sha256:..."—so that the service definition consistently
pulls the exact same image.
- Around line 13-15: The bind mount of /tmp/.X11-unix in docker-compose.yml
causes Docker to create an empty directory on headless hosts; move this mount
out of the main docker-compose.yml and into the generated override mechanism
used by generate-local-override.sh so it is only added when the host path
exists—follow the existing pattern in generate-local-override.sh (the [ -e
"$host_path" ] conditional) to conditionally include the /tmp/.X11-unix bind
mount for the service that currently lists source: /tmp/.X11-unix and target:
/tmp/.X11-unix.
In @.devcontainer/scripts/probe-host-tools.sh:
- Line 72: The printf invocation that prints a tip uses single quotes which
triggers ShellCheck SC2016; change the printf call that contains the literal
backticks and \n (the printf 'Tip: rerun `bash
/workspaces/RMCS/.devcontainer/scripts/bootstrap-tools.sh` to resync container
tool versions with the host.\n' line) to use double quotes for the format string
so the intent is explicit and the SC2016 warning is suppressed—keep the same
text and escape sequences unchanged, only replace the surrounding quotes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b03a8b13-6811-44a5-8266-ea5ce7e75fa9
📒 Files selected for processing (8)
.devcontainer/.gitignore.devcontainer/devcontainer.json.devcontainer/docker-compose.yml.devcontainer/scripts/bootstrap-tools.sh.devcontainer/scripts/generate-local-override.sh.devcontainer/scripts/probe-host-tools.sh.devcontainer/scripts/setup-shell-history.shDockerfile
Pull Request Summary
概述
该PR将devcontainer设置从基于镜像的配置转换为基于docker-compose的方案,并引入了本地环境配置生成和工具引导机制,使本地开发设置更加可重现。
主要变更
Docker Compose配置
新增
.devcontainer/docker-compose.yml:定义了rmcs-develop服务,使用qzhhhi/rmcs-develop:latest-full镜像,配置了特权模式、主机网络、init进程,并挂载了主机的/dev和/tmp/.X11-unix以及工作空间目录。更新
.devcontainer/devcontainer.json:image/privileged/mounts/runArgs的配置转换为基于dockerComposeFile和service的配置initializeCommand和postCreateCommand以执行初始化脚本twxs.cmake,添加KylinIdeTeam.cmake-intellisenceremote.autoForwardPorts: false配置本地环境配置脚本
新增
.devcontainer/scripts/generate-local-override.sh:.generated/docker-compose.local.override.yml本地覆盖文件HOST_WORKSPACE_FOLDER、display/代理设置)构建YAML条目新增
.devcontainer/scripts/probe-host-tools.sh:codex、claude、opencode、lark-cli)的存在性和版本.devcontainer/.generated/host-tools.manifest清单文件,记录工具版本和时间戳新增
.devcontainer/scripts/bootstrap-tools.sh:@openai/codex、@anthropic-ai/claude-code、opencode-ai、@larksuite/cli)引导安装到容器内Shell历史配置
.devcontainer/scripts/setup-shell-history.sh:.devcontainer/.zsh_history文件~/.zsh_history符号链接到仓库本地的历史文件,确保shell历史持久化Dockerfile更新
rmcs-develop阶段安装Node.js 24 LTS/home/ubuntu下),并设置正确的所有权.gitignore更新
.devcontainer/.gitignore:添加规则忽略.zsh_history和.generated/生成目录影响范围
此变更主要涉及开发容器的配置和引导流程,包括环境初始化、工具版本管理和shell历史持久化,为本地开发提供更一致的可重现环境。