# 例如 Atlas A3 镜像;Atlas A2 镜像(无 -a3)
FROM quay.io/ascend/vllm-ascend:v0.30.0-a3
USER root
RUN chmod -R a+rX "/vllm-workspace/vllm-ascend"
# 替换APT源为华为云
RUN echo "配置华为云APT源..." && \
cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
sed -i 's@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g' /etc/apt/sources.list && \
sed -i 's@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g' /etc/apt/sources.list && \
echo "华为云APT源配置完成"
# 安装基础系统工具
RUN apt-get update && \
apt-get install -y \
sudo \
zip \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG TARGETARCH
RUN echo "Building for architecture: $TARGETARCH" && \
case "$TARGETARCH" in \
amd64|x86_64) TTYD_URL="https://github.com/tsl0922/ttyd/releases/latest/download/ttyd.x86_64" ;; \
arm64|aarch64) TTYD_URL="https://github.com/tsl0922/ttyd/releases/latest/download/ttyd.aarch64" ;; \
*) echo "Unsupported arch: $TARGETARCH"; exit 1 ;; \
esac \
&& curl -fsSL "$TTYD_URL" -o /usr/local/bin/ttyd \
&& chmod +x /usr/local/bin/ttyd
# 安装 nginx 1.26(Ubuntu 官方源无此版本,使用 nginx.org stable 仓库)
RUN set -eux && \
apt-get update && \
apt-get install -y --no-install-recommends curl gnupg ca-certificates lsb-release && \
curl -fsSL https://nginx.org/keys/nginx_signing.key \
| gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg && \
CODENAME="$(. /etc/os-release && echo "$VERSION_CODENAME")" && \
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu $CODENAME nginx" \
> /etc/apt/sources.list.d/nginx.list && \
apt-get update && \
NGINX_VERSION="$(apt-cache madison nginx | awk '$3 ~ /^1\.26\./ {print $3; exit}')" && \
test -n "$NGINX_VERSION" && \
echo "安装 nginx 版本: $NGINX_VERSION" && \
apt-get install -y --no-install-recommends "nginx=$NGINX_VERSION" && \
apt-mark hold nginx && \
nginx -v && \
# 包自带的 default.conf 会被 include conf.d/*.conf 加载(listen 80),移除
rm -f /etc/nginx/conf.d/default.conf && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD docker/nginx.conf /etc/nginx/nginx.conf
ADD docker/conf.d/ /etc/nginx/conf.d/
WORKDIR /repositories
ARG CACHEBUST=1
# 凭据用 BuildKit secret 挂载,不写进镜像层(勿再用 COPY git-credentials)
# 子模块多为 git@gitcode.com:...,无 SSH;改为 HTTPS 后由 credential.helper 读挂载的凭据
RUN --mount=type=secret,id=git_credentials,target=/tmp/.git-credentials,required \
# 在 RUN 中引用该参数,让 Docker 认为该层依赖 CACHEBUST
test -n "${CACHEBUST}" \
&& set -eux \
&& cp /tmp/.git-credentials /root/.git-credentials \
&& git config --global credential.helper store \
&& git config --global url."https://gitcode.com/".insteadOf "git@gitcode.com:" \
&& export GIT_TERMINAL_PROMPT=0 \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/gmq123/mofix-new.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/adapt-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/deploy-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/doc-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/optimization-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/quantify-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/search-agent.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/gmq123/model-agent-eval-core.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/MoFixGo/verify-agent.git \
&& git clone --depth 1 --recurse-submodules -b v2.0.0 --single-branch https://gitcode.com/LucciC/pta-helper.git \
&& git clone https://gitee.com/lordstar-habile/huaweicloud-lts-python-sdk.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/cann/cannbot-skills.git \
&& git clone --depth 1 --recurse-submodules https://gitcode.com/Ascend/msagent.git \
&& git config --global --unset credential.helper \
&& git config --global --unset url."https://gitcode.com/".insteadOf \
&& rm -rf mofix-new/.git adapt-agent/.git deploy-agent/.git doc-agent/.git optimization-agent/.git quantify-agent/.git search-agent/.git verify-agent/.git \
&& rm -rf /root/.git-credentials
# 更换清华源
RUN mkdir -p /root/.config/pip \
&& echo "[global]" > /root/.config/pip/pip.conf && \
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.config/pip/pip.conf && \
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.config/pip/pip.conf && \
echo "timeout = 120" >> /root/.config/pip/pip.conf
RUN pip install ml-dtypes tornado \
&& pip install --no-cache-dir -r mofix-new/requirements.txt
# 安装pta-helper依赖知识库
RUN python pta-helper/pta_helper.py --setup
# 安装 claude-agent-sdk(指定版本确保兼容性)
RUN pip install --no-cache-dir claude-agent-sdk==0.2.110
# 安装 Node.js 22.x(Claude Code CLI 需要;前端构建 pnpm@11 要求 Node >= 22.13)
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# 安装 Claude Code CLI
RUN npm install -g @anthropic-ai/claude-code
# ── 构建 ModelAgent 前端并交给 nginx 托管(与后端同一镜像 / 同一容器,统一从 8500 进入)──
# 该仓库是公开仓库,可直接 clone,无需 gitcode 凭据。
# 仓库地址可用 --build-arg MODEL_AGENT_OFFLINE_REPO=... 覆盖;
# 构建缓存通过上方 ARG CACHEBUST 失效:前端代码更新后带新 CACHEBUST 重新构建即可。
ARG MODEL_AGENT_OFFLINE_REPO=https://gitcode.com/yourleige/model-agent-offline.git
RUN test -n "${CACHEBUST}" \
&& set -eux \
&& npm install -g pnpm@11 \
&& mkdir -p /build \
&& git clone --depth 1 "${MODEL_AGENT_OFFLINE_REPO}" /build/model-agent-offline \
&& cd /build/model-agent-offline \
&& pnpm install \
&& pnpm build \
&& mkdir -p /usr/share/nginx/html \
&& cp -rf dist/. /usr/share/nginx/html/ \
&& rm -rf /build/model-agent-offline
# 安装 atomcode 命令行工具
RUN curl -fsSL https://raw.atomgit.com/atomgit_atomcode/atomcode/raw/main/scripts/install.sh | sh
# 安装插件
RUN atomcode plugin marketplace add https://gitcode.com/gmq123/ascend-model-agent-plugin
RUN atomcode plugin install ascend-model-agent-plugin@ascend-model-agent-plugin
RUN mv /root/.atomcode /workspace
RUN echo "创建 atomgit 用户与用户组..." && \
groupadd -g 1000 -r atomgitgroup && \
useradd -u 1000 -m -g atomgitgroup -s /bin/bash atomgit && \
usermod -aG sudo atomgit && \
echo "atomgit ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/atomgit && \
chmod 0440 /etc/sudoers.d/atomgit && \
mkdir -p /opt/atomgit && \
chown -R atomgit:atomgitgroup /opt/atomgit && \
echo "✅ atomgit 用户已创建并授予 sudo 权限"
RUN mkdir -p /workspace \
&& cd /repositories && zip -qr /workspace/mofix-new.zip . \
&& mv mofix-new/skills /workspace/ \
&& chown -R atomgit:atomgitgroup /workspace \
&& rm -rf /repositories
# -------------------------------------------------------------
# 依然保持 root 身份处理文件创建与权限分配
# -------------------------------------------------------------
RUN mkdir -p /opt/atomgit/.claude /home/atomgit/.claude
# 1. 复制 settings.json 并直接指定属主为 atomgit
COPY --chown=atomgit:atomgitgroup docker/settings.json /home/atomgit/.claude/settings.json
# 2. 移动 skills 并统一将 /home/atomgit 目录下的所有文件改权给 atomgit 用户
RUN mv /workspace/skills /opt/atomgit/.claude/ \
&& chown -R atomgit:atomgitgroup /opt/atomgit \
&& chown -R atomgit:atomgitgroup /home/atomgit
# Claude 配置文件由部署时动态写入,配置来源
# 以下为参考示例(可按需要在此处修改 token)
#RUN echo '{ \
# "env": { \
# "ANTHROPIC_BASE_URL": "https://api.kimi.com/coding/", \
# "ANTHROPIC_AUTH_TOKEN":"sk-kimi-xxxxxxxxxxxx", \
# "ANTHROPIC_MODEL": "kimi-xx", \
# "ANTHROPIC_SMALL_FAST_MODEL": "kimi-xx", \
# "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", \
# "API_TIMEOUT_MS": "600000" \
# } \
#}' > ~/.claude/settings.json
USER atomgit
# 创建工作目录
WORKDIR /opt/atomgit
# 暴露端口
EXPOSE 8500
# 启动脚本(源文件无执行位,用 --chmod 直接赋权,避免非 root 用户下无法 chmod)
COPY --chown=atomgit:atomgitgroup --chmod=0755 docker/start.sh /usr/local/bin/start.sh
ENTRYPOINT ["/usr/local/bin/start.sh"]