Skip to content

feat(devcontainer): add compose-based local devcontainer bootstrap#65

Merged
qzhhhi merged 1 commit intomainfrom
dev/agent-tool
May 2, 2026
Merged

feat(devcontainer): add compose-based local devcontainer bootstrap#65
qzhhhi merged 1 commit intomainfrom
dev/agent-tool

Conversation

@qzhhhi
Copy link
Copy Markdown
Member

@qzhhhi qzhhhi commented May 2, 2026

  • 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.

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的配置转换为基于dockerComposeFileservice的配置
    • 添加了initializeCommandpostCreateCommand以执行初始化脚本
    • 移除了之前的环境变量和设备挂载配置
    • 更新VS Code扩展列表:移除twxs.cmake,添加KylinIdeTeam.cmake-intellisence
    • 添加了remote.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

    • 探测主机CLI工具(codexclaudeopencodelark-cli)的存在性和版本
    • 生成.devcontainer/.generated/host-tools.manifest清单文件,记录工具版本和时间戳
  • 新增 .devcontainer/scripts/bootstrap-tools.sh

    • 根据主机工具清单,将指定的npm包(@openai/codex@anthropic-ai/claude-codeopencode-ai@larksuite/cli)引导安装到容器内
    • 支持版本控制和安装失败处理

Shell历史配置

  • 新增 .devcontainer/scripts/setup-shell-history.sh
    • 创建.devcontainer/.zsh_history文件
    • 将容器内~/.zsh_history符号链接到仓库本地的历史文件,确保shell历史持久化

Dockerfile更新

  • rmcs-develop阶段安装Node.js 24 LTS
  • 为bind-mounted卷预创建XDG标准目录结构(在/home/ubuntu下),并设置正确的所有权

.gitignore更新

  • .devcontainer/.gitignore:添加规则忽略.zsh_history.generated/生成目录

影响范围

此变更主要涉及开发容器的配置和引导流程,包括环境初始化、工具版本管理和shell历史持久化,为本地开发提供更一致的可重现环境。

- 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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Walkthrough

开发容器配置从基于单一镜像的设置重构为 Docker Compose 驱动方案。新增四个引导脚本分别用于探测宿主工具、生成本地覆盖配置、启动全局包管理工具和配置 Shell 历史。Dockerfile 中添加了 Node.js 24 LTS 和 XDG 目录预创建。

Changes

开发容器环境重构

Layer / File(s) Summary
基础架构配置
.devcontainer/docker-compose.yml, Dockerfile
引入 Docker Compose 服务定义(rmcs-develop),配置特权模式、主机网络和设备/卷挂载。Dockerfile 添加 Node.js 24 LTS 和预创建 /home/ubuntu XDG 目录。
DevContainer 元数据
.devcontainer/devcontainer.json
从直接镜像配置迁移至 dockerComposeFile + service 范式,加入 initializeCommandpostCreateCommand 钩子。移除环境变量透传和设备绑定配置。更新 VS Code 扩展清单(移除 twxs.cmake,添加 KylinIdeTeam.cmake-intellisence),启用 remote.autoForwardPorts: false
宿主工具探测
.devcontainer/scripts/probe-host-tools.sh
新增脚本,探测 codexclaudeopencodelark-cli 工具的存在性和版本,输出至 .generated/host-tools.manifest。定义 parse_version()probe_tool() 辅助函数用于版本字符串解析。
工具引导安装
.devcontainer/scripts/bootstrap-tools.sh
新增脚本,从宿主工具清单读取预期版本,通过 sudo npm install -g package@version 为选定的全局包执行安装。包含版本格式校验和跳过原因追踪。
本地覆盖配置生成
.devcontainer/scripts/generate-local-override.sh
新增脚本,动态生成 .generated/docker-compose.local.override.yml,从环境变量(如 HOST_WORKSPACE_FOLDER、代理配置)和宿主路径存在性构建 YAML 环境和卷挂载条目。实现 YAML 双引号转义函数。
Shell 历史配置
.devcontainer/scripts/setup-shell-history.sh
新增脚本,在 .devcontainer/.zsh_history 处创建历史文件并将 ~/.zsh_history 符号链接指向该位置,实现跨容器会话的历史共享。
忽略规则
.devcontainer/.gitignore
新增规则忽略 .zsh_history.generated/ 目录。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 新的开发空间焕然一新,
Docker Compose 织就网络之网,
脚本四重奏和谐共鸣,
宿主与容器一心同德,
Shell 历史永驻于心!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了变更的主要内容,即将devcontainer设置迁移到docker-compose并添加本地引导程序。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/agent-tool

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
.devcontainer/scripts/probe-host-tools.sh (1)

72-72: 💤 Low value

可选:用双引号消除 ShellCheck SC2016 警告

此处 ` 是纯字面字符(用于 Markdown 风格代码展示),\nprintf 正常解释——单引号版本功能上完全正确。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

📥 Commits

Reviewing files that changed from the base of the PR and between 23d3469 and da05d4e.

📒 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.sh
  • Dockerfile

@qzhhhi qzhhhi merged commit fc0bb78 into main May 2, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in RMCS May 2, 2026
@qzhhhi qzhhhi deleted the dev/agent-tool branch May 2, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant