diff --git a/app/Dockerfile b/app/Dockerfile index ec087c0..f1bee0d 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -4,8 +4,13 @@ ENV TZ=Asia/Shanghai WORKDIR /app +# 国内构建慢:npm 默认源在国外。默认换成腾讯云 npm 镜像(与宿主机 ~/.npmrc 一致)。 +# 想换回官方:docker compose build --build-arg NPM_REGISTRY=https://registry.npmjs.org/ +ARG NPM_REGISTRY=https://mirrors.cloud.tencent.com/npm/ + COPY package.json package-lock.json ./ -RUN npm install --omit=dev --no-audit --no-fund +RUN npm config set registry "$NPM_REGISTRY" \ + && npm install --omit=dev --no-audit --no-fund COPY server ./server COPY config.example.yml ./ diff --git a/docs/DEPLOY.md b/docs/DEPLOY.md index 4307341..6db150d 100644 --- a/docs/DEPLOY.md +++ b/docs/DEPLOY.md @@ -114,6 +114,10 @@ docker compose logs -f agent-core # 看到 "Agent server listening on 8080" 首次启动会先跑一次 `agent-executor-init`(把技能依赖落到宿主机 `./skills`),跑完自动退出, 属正常现象。 +> 镜像构建默认走腾讯云镜像源(apt / pip / npm),否则国内机器上 `apt-get update` 可以卡十几分钟。 +> 境外构建或想换源:`docker compose build --build-arg DEBIAN_MIRROR=deb.debian.org agent-executor` +> (mcp 仓库同理,参数名是 `NPM_REGISTRY`)。腾讯云 CVM 上还可换成内网镜像 `mirrors.tencentyun.com`。 + ## 4. 访问 浏览器打开 **`http://<服务器IP>:8090`**(端口可用 `.env` 里的 `AGENT_PORT` 改)。 diff --git a/executor/Dockerfile b/executor/Dockerfile index b196bc8..7d03874 100644 --- a/executor/Dockerfile +++ b/executor/Dockerfile @@ -5,6 +5,23 @@ # ============================================================================= FROM node:20-slim AS base +# 国内构建慢:apt/pip 默认源在国外,apt-get update 能卡十几分钟。默认换成腾讯云镜像。 +# 境外构建或想换源:docker compose build --build-arg DEBIAN_MIRROR=deb.debian.org +# 腾讯云 CVM 上想更快可用内网镜像 mirrors.tencentyun.com(仅腾讯云内网可达)。 +ARG DEBIAN_MIRROR=mirrors.cloud.tencent.com +ARG PIP_INDEX_URL=https://mirrors.cloud.tencent.com/pypi/simple + +# PIP_INDEX_URL 烘进镜像 env:运行期(如 agent-executor-init 的 pip --target 装技能依赖)也走镜像,不再卡 pypi +ENV PIP_INDEX_URL=${PIP_INDEX_URL} \ + PIP_DISABLE_PIP_VERSION_CHECK=1 + +# 换 apt 源:bookworm 可能是 /etc/apt/sources.list,也可能是 deb822 的 /etc/apt/sources.list.d/*.sources, +# 直接用 grep 扫一遍、只替换域名,两种格式都盖住(路径 /debian、/debian-security 保持不变)。 +RUN set -eux; \ + files="$(grep -rl 'deb.debian.org' /etc/apt/ 2>/dev/null || true)"; \ + if [ -n "$files" ]; then sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" $files; fi; \ + grep -rn "${DEBIAN_MIRROR}" /etc/apt/ | head -5 || true + # MPLBACKEND=Agg:让 matplotlib 使用非交互式后端,避免缺少显示设备报错。 # PYTHONUNBUFFERED=1:实时输出日志。 # PYTHONPYCACHEPREFIX=/tmp/pycache:把 __pycache__ 统一甩到会话私有 tmpfs,绝不回写 skills(已 :ro)。 @@ -15,6 +32,7 @@ ENV MPLBACKEND=Agg \ PYTHONPYCACHEPREFIX=/tmp/pycache \ PYTHONDONTWRITEBYTECODE=1 \ PIP_BREAK_SYSTEM_PACKAGES=1 \ + DEBIAN_FRONTEND=noninteractive \ TZ=Asia/Shanghai # 常用命令行工具:Agent 的 terminal 工具经常用到