已合并
【feature】支持 Dev Container 开发环境 #349
【feature】支持 Dev Container 开发环境 #349
已合并
liguo创建于 7月9日
liguo
liguo成员
7月9日

合入来源

  • [ √] issue

问题/功能描述

支持 Dev Container 开发环境。基于昇腾 vLLM-Ascend 官方镜像构建开箱即用的容器化开发环境,解决"本地环境不一致、CANN/PyTorch/vLLM 工具链手工安装繁琐、新成员上手成本高"的问题,实现 git clone → Open in Container 即可获得与 CI 一致的完整构建链。

修改方案描述

支持 Dev Container 开发环境。基于昇腾 vLLM-Ascend 官方镜像构建开箱即用的容器化开发环境,解决"本地环境不一致、CANN/PyTorch/vLLM 工具链手工安装繁琐、新成员上手成本高"的问题,实现 git clone → Open in Container 即可获得与 CI 一致的完整构建链。
image.png

是否涉及UT/ST

  • [√ ] 否(不涉及源码修改,不需要 ut/st)

开发自检

  • [√ ] 规范:未超过1k;超过1k已完成备案;反合入需要标题注明【反合】
  • [√ ] 规范:已关联issue或里程碑
  • [ √] 规范:不需要UT/ST且已说明理由;需要且已包含UT/ST
  • [ √] 安全:未引入三方开源软件;引入三方开源软件并经过安全评审
  • [ √] 安全:未新增对外接口/参数;新增对外接口/参数有校验
  • [ √] 规范:未涉及资料改动;涉及资料改动并已完成修改
    image.png
    image.png

image.png
image.png

image.png

likedislike
Pull Request已成功合入, 合并人@chenxin
(感谢 liguo 的贡献)
liguoliguo成员
7月9日 关联了issue:[Feature] 支持 Dev Container 开发环境
atomgit-bot
atomgit-bot
7月9日 评论:

变更摘要

此 PR 为 MemCache 项目新增 Dev Container 开发环境支持,基于昇腾 vLLM-Ascend 官方镜像(quay.nju.edu.cn/ascend/vllm-ascend:v0.20.2rc1-a3)构建开箱即用的容器化开发环境,实现 git clone → Open in Container 即可获得与 CI 一致的完整构建链(CANN、PyTorch、vLLM 工具链预装)。共涉及 6 个文件变更,新增约 523 行,主要包括容器镜像定义、VS Code Dev Container 配置及容器启动引导脚本。

主要改动

  • 新增 .devcontainer/Dockerfile:基于 quay.nju.edu.cn/ascend/vllm-ascend:v0.20.2rc1-a3 镜像构建开发容器,额外安装 doxygengraphvizgdbvalgrindstraceltracecgdb 等调试与文档工具,配置阿里云 pip 镜像源并输出工具链版本信息用于快速验证。
  • 新增 .devcontainer/devcontainer.json:定义容器构建与运行时配置,包括以 --network=host--privileged 模式运行、挂载昇腾 NPU 驱动设备(/dev/davinci_manager 等)及宿主机目录(/mnt/home/root),注入 PYTHONUNBUFFEREDCMAKE_BUILD_PARALLEL_LEVEL 等环境变量,预装 Python/C++/CMake/Ruff 等 VS Code 扩展并配置编辑器格式化与缩进规则。
  • 新增 .devcontainer/post_create.sh:容器创建后的引导脚本,依次执行 git 子模块初始化(git submodule update --init 3rdparty/)、Python 开发依赖安装(pip3 install -r requirements.txt)、构建工具链版本验证、CMake 配置冒烟测试以及 pre-commit 钩子安装。
  • 新增 .devcontainer/requirements.txt(由 Dockerfile 与 post_create.sh 引用推断):提供项目 Python 开发依赖清单,在镜像构建阶段和容器启动阶段分别被 pip install 调用。
likedislike
atomgit-bot
atomgit-bot
7月9日 评论:

代码审查

审查总结

已完成对所有 6 个变更文件的逐文件审查:

文件 审查结果
.devcontainer/Dockerfile 发现 1 个问题(P3:死代码 COPY)
.devcontainer/devcontainer.json 发现 3 个问题(P2:宿主机敏感路径挂载;P3×2:无效环境变量、单文件 bind mount 风险)
.devcontainer/post_create.sh 发现 1 个问题(P3:与 postStartCommand 重复初始化 submodule)
.devcontainer/requirements.txt 无问题
README.md 无问题(仅格式化清理 + 文档链接新增)
doc/devcontainer_quickstart.md 发现 1 个问题(P3:Docker 镜像版本号与 Dockerfile 不一致)

总体风险判断:中低风险。

  • P2(1 项)/root/home 的 bind mount 将宿主机敏感路径暴露给 privileged 容器,存在凭证泄露风险。这是最需要关注的安全问题。
  • P3(5 项):均为非阻断性问题——死代码、无效配置、重复操作、文档不一致、挂载路径健壮性不足。不影响核心功能但建议修复以提升代码质量和可维护性。

该 PR 整体实现了 Dev Container 开发环境的目标,核心逻辑正确,无 P0/P1 级阻断性问题。建议在合入前至少处理 P2 的 /root + /home bind mount 安全问题。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
ascend-robot
ascend-robot成员
7月9日 评论:
流水线 PR-pipeline_memcache#1395 [ commitID:1bd3fa15 ] 已完成
阶段 任务名 状态 详情
编译构建 Build_memcache >>>
恶意代码检查 Antipoison_memcache >>>
编码安全与规范检查 pre-commit >>>
CodeCheck_memcache >>>
开源片段检查 SCA_memcache >>>
开发者测试 UT_memcache >>>
流水线 PR-pipeline_memcache >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
xiangjie10成员
7月9日 评论:
🔍 PR 规范审计未通过,以下项目需要修正:
  • ⚠️ PR 代码变更未包含测试用例(变更文件路径中均不包含 test 或 ut),请确认已经备注原因!

请修正后重新提交,或联系仓库管理员。

likedislike
ascend-robotascend-robot成员
7月9日 添加了label:ascend-cla/yes
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
7月9日 评论:

CLA Signature Pass

littleyellowbicycle, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robot
ascend-robot成员
7月9日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 3 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-Ascend/memcache ❌ (0/3)(You can also ask: stonezy, yangjingyao, 陈元明, liujp20, zja4gitcode) ❌ (0/1)(You can also ask: wang-ruiju, yuncliu, liu1103xwxw, 程俊华, shepherd-cheung)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

littleyellowbicycle, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
atomgit-bot
atomgit-bot7月9日进行代码检视2
.devcontainer/devcontainer.json
@@ -0,0 +20,4 @@
20+ "source=memcache-precommit-cache-${localEnv:USER:unknown},target=/root/.cache/pre-commit,type=volume",
21+ "source=/mnt,target=/mnt,type=bind,consistency=cached",
22+ "source=/home,target=/home,type=bind,consistency=cached",
23+ "source=/root,target=/root,type=bind,consistency=cached"
atomgit-bot
atomgit-bot7月9日评论:

🟡 Medium Priority

devcontainer.json 第 22-23 行将宿主机的 /home/root 以 bind mount 方式直接映射到容器内。容器以 remoteUser: "root" 运行且带有 --privileged,因此容器内的 root 用户可读写宿主机 /root 目录下的所有文件,包括 ~/.ssh/(SSH 私钥)、~/.docker/(Docker 凭证)、~/.bash_history 等敏感数据。/home 的挂载同样暴露所有用户的 home 目录。

触发条件:任何在容器内以 root 身份运行的进程均可访问这些路径。如果容器内的软件(如 VS Code 扩展、pip 包、恶意依赖)存在漏洞或被篡改,宿主机 root 凭证将直接暴露。

建议:移除 /home/root 的 bind mount(第 22-23 行),改为按需挂载仅需要的子目录。/root/.cache/pip/root/.ccache/root/.cache/pre-commit 已有独立的 named volume,不需要整体挂载 /root

likedislike
liguo
liguo成员
7月9日 评论:

常用模型权重挂在目录喝个人数据保存目录,保留

ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-failed
liguo
liguo成员
7月9日 评论:

retry

likedislike
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-running
liguo
liguo成员
7月9日 评论:

retry

likedislike
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-running
此处折叠了6条事件消息 查看更多
ascend-robotascend-robot成员
7月11日 删除了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月11日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
ascend-robotascend-robot成员
7月11日 添加了label:ci-pipeline-running
此处折叠了20条事件消息 查看更多
chenxinchenxin成员
7月13日 合入了pull request