添加qiming-rcoder模块

This commit is contained in:
Codex
2026-06-01 13:54:52 +08:00
parent 8092c4b1f8
commit 4b1a580132
539 changed files with 151650 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[source.aliyun]
registry = "https://mirrors.aliyun.com/crates.io-index"
[source.aliyun-sparse]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
[source.tencent]
registry = "https://mirrors.cloud.tencent.com/crates.io-index"
[source.tencent-sparse]
registry = "sparse+https://mirrors.cloud.tencent.com/crates.io-index/"
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
[source.ustc-sparse]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true

View File

@@ -0,0 +1 @@
registry=https://registry.npmmirror.com/

View File

@@ -0,0 +1,128 @@
# ============================================================================
# 最终镜像 Dockerfile - master-rcoder
# ============================================================================
# 此 Dockerfile 使用多阶段构建:
# 1. 第一阶段:在 node:22 中构建 Rust 项目
# 2. 第二阶段:基于 master-rcoder-base 基础镜像运行
# ============================================================================
# 全局 ARG 声明(必须在第一个 FROM 之前,才能在后续 FROM 中使用)
ARG BASE_IMAGE=master-rcoder-base:latest
# ============================================================================
# 第一阶段:构建 Rust 项目
# ============================================================================
FROM node:22 AS rust-builder
# 设置环境变量避免交互式提示
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 设置 ARG TARGETARCH
ARG TARGETARCH
# 设置工作目录
WORKDIR /build
# 使用 LinuxMirrors 一键配置阿里云镜像源
# 参考: https://github.com/SuperManito/LinuxMirrors
RUN curl -sSL https://linuxmirrors.cn/main.sh | bash -s -- \
--source mirrors.aliyun.com \
--protocol https \
--use-intranet-source false \
--install-epel false \
--backup false \
--upgrade-software false \
--clean-cache true \
--ignore-backup-tips
# 安装构建依赖包括cmake和protoc
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
pkg-config \
protobuf-compiler \
libprotobuf-dev \
&& rm -rf /var/lib/apt/lists/*
# 安装 Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. /root/.cargo/env && cargo --version
ENV PATH="/root/.cargo/bin:${PATH}"
# 复制整个项目源代码(通过 .dockerignore 排除不需要的文件)
COPY . .
# 🔧 支持 CARGO_FLAGS 参数,允许外部传递 feature flags
ARG CARGO_FLAGS=""
RUN echo "🔧 Cargo flags: ${CARGO_FLAGS}" && \
cargo build --release --bin rcoder --bin agent_runner ${CARGO_FLAGS}
# ============================================================================
# 第二阶段:运行阶段(基于基础镜像)
# ============================================================================
# 重新声明 ARGFROM 之后需要重新声明才能使用)
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
# 设置工作目录
WORKDIR /app
# 安装 git用于 nuwaxcode 源码安装)
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
# 复制 .npmrc 文件
COPY docker/rcoder-master/.npmrc /root/.npmrc
# 创建 bin 目录并复制构建产物
RUN mkdir -p /app/bin
COPY --from=rust-builder /build/target/release/rcoder /app/bin/rcoder
COPY --from=rust-builder /build/target/release/agent_runner /app/bin/agent_runner
# 只有在二进制文件存在时才复制避免feature构建时的错误
RUN if [ -f /build/target/release/codex-acp-agent ]; then \
cp /build/target/release/codex-acp-agent /app/bin/codex-acp-agent; \
fi
# 设置执行权限
RUN chmod +x /app/bin/rcoder /app/bin/agent_runner
# 使用构建参数破坏缓存(每次构建都获取最新版本的工具)
ARG CACHEBUST=1
# agent install
RUN echo "Cache bust: ${CACHEBUST}" && npm install -g claude-code-acp-ts@latest
# # 安装 claude-code-acp-ts从源码构建用于测试
# # 使用 npm pack + npm install -g <tarball> 确保复制文件而非 symlink
# RUN echo "Cache bust: ${CACHEBUST}" && \
# rm -rf /tmp/claude-code-acp-ts && \
# git clone -b feat/claude-code-acp-ts https://github.com/nuwax-ai/claude-code-acp-ts.git /tmp/claude-code-acp-ts && \
# cd /tmp/claude-code-acp-ts && npm install && npm run build && \
# npm pack . && \
# npm install -g ./claude-code-acp-ts-*.tgz && \
# echo "验证 claude-code-acp-ts 安装..." && \
# (which claude-code-acp-ts > /dev/null 2>&1 && echo "✅ claude-code-acp-ts 安装验证通过") || (echo "❌ claude-code-acp-ts 未正确安装" && exit 1)
# 安装 nuwaxcode频繁更新的工具放在最终镜像以加快构建
# 使用 CACHEBUST 变量触发缓存失效
RUN echo "Cache bust: ${CACHEBUST}" && npm i -g nuwaxcode@latest
# 安装 nuwax-file-server文件服务器
RUN echo "Cache bust: ${CACHEBUST}" && npm i -g nuwax-file-server@latest
# 配置 nuwaxcode - 禁用 websearch, webfetch 和 question 权限
RUN mkdir -p /root/.config/opencode && \
echo '{\n "permission": {\n "websearch": "deny",\n "webfetch": "deny",\n "question": "deny"\n }\n}' > /root/.config/opencode/opencode.json
# 暴露端口
EXPOSE 8086
EXPOSE 60000
EXPOSE 80

View File

@@ -0,0 +1,149 @@
# ============================================================================
# 基础镜像 Dockerfile - master-rcoder-base
# ============================================================================
# 此镜像包含所有运行时依赖、工具链和环境配置,不包含业务代码
# 构建命令: make docker-build-master-base
# 平时不需要重新构建,只有在修改系统依赖时才需要重新构建
# ============================================================================
FROM node:22
# 设置环境变量
ENV TZ=Asia/Shanghai
# 使用 LinuxMirrors 一键配置阿里云镜像源
# 参考: https://github.com/SuperManito/LinuxMirrors
# node:22 基础镜像已预装 curl可直接执行脚本配置镜像源
RUN curl -sSL https://linuxmirrors.cn/main.sh | bash -s -- \
--source mirrors.aliyun.com \
--protocol https \
--use-intranet-source false \
--install-epel false \
--backup false \
--upgrade-software false \
--clean-cache true \
--ignore-backup-tips
# 安装必要的运行时依赖apt 包管理器)
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
wget \
gnupg \
unzip \
zip \
tzdata \
lsof \
iproute2 \
net-tools \
nginx \
vim \
fonts-liberation \
lsb-release \
xdg-utils \
chromium \
chromium-driver \
&& rm -rf /var/lib/apt/lists/* \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
# 复制 npmrc 配置镜像(使用国内镜像加速)
COPY .npmrc /root/.npmrc
# 配置 npm 使用国内镜像源
RUN npm config set registry https://registry.npmmirror.com
# 安装 pnpm
RUN npm install -g pnpm
# 配置 pnpm 使用国内镜像源
RUN pnpm config set registry https://registry.npmmirror.com
# 创建 pnpm 全局存储目录
RUN mkdir -p /app/project_workspace/.pnpm-store
# 配置 pnpm 使用新的存储路径
RUN pnpm config set store-dir /app/project_workspace/.pnpm-store
# 配置 yarn 使用国内镜像源
RUN yarn config set registry https://registry.npmmirror.com
# 安装 vite最新版本
RUN npm install -g vite@latest
# 安装额外的命令工具(强制更新到最新版本)
RUN npm install -g @zed-industries/claude-code-acp@latest
# 安装 Claude CLI 工具(强制更新到最新版本)
RUN npm install -g @anthropic-ai/claude-code@latest
# 安装 OpenAI Codex强制更新到最新版本
RUN npm install -g @openai/codex@latest
# 安装 Chrome DevTools MCP强制更新到最新版本
RUN npm install -g chrome-devtools-mcp@latest
# 安装 Bun使用 npm 从阿里云 npmmirror 安装 prebuilt 二进制,避免从 bun.sh/install 走 GitHub 下载不稳定)
# bun 的 npm 包通过 optionalDependencies 引入平台特定二进制(如 @oven/bun-linux-x64npmmirror 已镜像
# --prefix=/usr/local 让 bun 安装到 /usr/local/bin/bun默认就在 PATH 中,无需额外 ENV
RUN npm install -g --prefix=/usr/local --registry=https://registry.npmmirror.com bun && \
/usr/local/bin/bun --version
# Bun 运行时配置bun install 使用的 registry
RUN echo '[install]' > /root/.bunfig.toml && \
echo 'registry = "https://registry.npmmirror.com"' >> /root/.bunfig.toml && \
echo '' >> /root/.bunfig.toml && \
echo '[install.scopes]' >> /root/.bunfig.toml && \
# @upstash scope 走 npmmirror 加速bun 装 @upstash 包默认从这里下载,国内速度快
# 注意bun 与 npmmirror 的 tarball 校验存在偶发性 bug#21493但 docker build 期
# 预装 context7-mcp 时已用 --registry npmjs.org 命令行参数覆盖,避开 build 失败
# 运行时 bunx @upstash/context7-mcp 会命中 ~/.bun/install/global 全局缓存,无需再下载
echo '"@upstash" = "https://registry.npmmirror.com"' >> /root/.bunfig.toml
# 安装 python3-pipnode:22 基础镜像默认不带 Python用 pip 装 uv 需要先安装)
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip && \
rm -rf /var/lib/apt/lists/*
# 安装 uv 并验证(使用 pip 从阿里云 PyPI 镜像安装,避免从 astral.sh 下载二进制慢/不稳定)
# --break-system-packages: Debian 12+ 的 PEP 668 限制,系统 Python 默认不允许直接 pip install
RUN pip3 install --break-system-packages --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple uv && \
uv --version || (echo "ERROR: uv installation failed" && exit 1)
# 设置 uv 镜像加速地址
ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
# 设置工作目录
WORKDIR /app
# 创建 bin 目录
RUN mkdir -p /app/bin
# 预安装 MCP 工具到 uv 缓存中
RUN uv tool install mcp-server-fetch
# 预安装 context7 MCP 工具Bun 全局安装)
# 代码里通过 bunx 调用 MCP预装到 bun 全局后 bunx 可直接命中 ~/.bun/install/global无需运行时再下载
RUN bun add -g @upstash/context7-mcp
# 创建 Claude Code 配置目录并禁用 webfetch 功能,添加 MCP 工具
RUN mkdir -p /root/.claude && \
echo '{"permissions":{"deny":["WebFetch", "WebSearch"]},"mcpServers":{"mcp-fetch":{"args":["mcp-server-fetch"],"command":"uvx"},"chrome-devtools":{"command":"npx","args":["-y","chrome-devtools-mcp@latest"]}}}' > /root/.claude/settings.json
# 添加所有工具安装路径到 PATH
ENV PNPM_HOME="/home/user/.local/share/pnpm" \
PATH="/app/bin:/root/.local/bin:/home/user/.local/bin:/home/user/.local/share/pnpm:/opt/cargo/bin:/usr/local/bin:${PATH}"
# 清理默认nginx配置以避免冲突
RUN rm -f /etc/nginx/sites-enabled/default && \
rm -f /etc/nginx/conf.d/default.conf
# ============================================================================
# 基础镜像构建完成
# ============================================================================
# 此处不设置 ENTRYPOINT/CMD由最终镜像设置
# 暴露端口(供最终镜像使用)
EXPOSE 8086
EXPOSE 60000
EXPOSE 80