集成新的Beaver后端服务到应用实例中,替换原有的nanobot实现。 主要变更包括: - 在Dockerfile和环境配置中添加Beaver相关路径和配置变量 - 更新工作目录结构从.nanobot到.beaver - 实现Beaver引擎加载器,支持配置文件加载和工具组装 - 添加内置工具如ListDirectoryTool、ReadFileTool、SearchFilesTool - 更新消息处理流程,支持通道适配器和网关模式 - 重构技能系统,支持显式工具提示和嵌入式检索 - 改进错误处理和生命周期管理 此变更使应用实例能够使用统一的Beaver后端进行AI代理运行时管理。
88 lines
3.0 KiB
Docker
88 lines
3.0 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
FROM node:20-bookworm-slim AS frontend-builder
|
|
|
|
WORKDIR /build/frontend
|
|
ENV CI=1 NEXT_TELEMETRY_DISABLED=1
|
|
|
|
ARG NPM_REGISTRY="https://registry.npmmirror.com"
|
|
ARG NPM_FETCH_RETRIES="5"
|
|
ARG NPM_FETCH_RETRY_MIN_TIMEOUT="20000"
|
|
ARG NPM_FETCH_RETRY_MAX_TIMEOUT="120000"
|
|
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm config set registry "${NPM_REGISTRY}" && \
|
|
npm config set fetch-retries "${NPM_FETCH_RETRIES}" && \
|
|
npm config set fetch-retry-mintimeout "${NPM_FETCH_RETRY_MIN_TIMEOUT}" && \
|
|
npm config set fetch-retry-maxtimeout "${NPM_FETCH_RETRY_MAX_TIMEOUT}" && \
|
|
npm ci
|
|
|
|
COPY frontend/ ./
|
|
|
|
ARG NEXT_PUBLIC_AUTH_PORTAL_URL=""
|
|
ARG NEXT_PUBLIC_AUTH_PORTAL_PORT="3081"
|
|
|
|
ENV NEXT_PUBLIC_AUTH_PORTAL_URL=${NEXT_PUBLIC_AUTH_PORTAL_URL}
|
|
ENV NEXT_PUBLIC_AUTH_PORTAL_PORT=${NEXT_PUBLIC_AUTH_PORTAL_PORT}
|
|
|
|
# API / WS 走同域反代,不在构建时写死实例地址。
|
|
RUN npm run build
|
|
|
|
|
|
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS runtime
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
APP_PUBLIC_PORT=8080 \
|
|
APP_FRONTEND_PORT=3000 \
|
|
APP_BACKEND_PORT=18080 \
|
|
BEAVER_HOME=/root/.beaver \
|
|
BEAVER_CONFIG_PATH=/root/.beaver/config.json \
|
|
BEAVER_WORKSPACE=/root/.beaver/workspace \
|
|
NANOBOT_AUTH_FILE=/root/.beaver/web_auth_users.json \
|
|
PORT=3000 \
|
|
HOSTNAME=127.0.0.1
|
|
|
|
ARG NPM_REGISTRY="https://registry.npmmirror.com"
|
|
ARG NPM_FETCH_RETRIES="5"
|
|
ARG NPM_FETCH_RETRY_MIN_TIMEOUT="20000"
|
|
ARG NPM_FETCH_RETRY_MAX_TIMEOUT="120000"
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends curl ca-certificates gnupg git nginx dumb-init && \
|
|
mkdir -p /etc/apt/keyrings && \
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends nodejs && \
|
|
apt-get purge -y gnupg && \
|
|
apt-get autoremove -y && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /opt/app/backend
|
|
|
|
COPY backend/pyproject.toml backend/README.md ./
|
|
COPY backend/beaver/ ./beaver/
|
|
RUN uv pip install --system --no-cache .
|
|
|
|
WORKDIR /opt/app/frontend
|
|
COPY --from=frontend-builder /build/frontend/next.config.js ./
|
|
COPY --from=frontend-builder /build/frontend/public ./public
|
|
COPY --from=frontend-builder /build/frontend/package.json ./package.json
|
|
COPY --from=frontend-builder /build/frontend/.next/standalone ./
|
|
COPY --from=frontend-builder /build/frontend/.next/static ./.next/static
|
|
|
|
WORKDIR /opt/app
|
|
COPY nginx.conf /opt/app/nginx.conf
|
|
COPY entrypoint.sh /opt/app/entrypoint.sh
|
|
|
|
RUN chmod +x /opt/app/entrypoint.sh && \
|
|
mkdir -p /var/lib/nginx/body /root/.beaver/workspace
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=5 \
|
|
CMD curl -fsS "http://127.0.0.1:${APP_PUBLIC_PORT}/api/ping" >/dev/null || exit 1
|
|
|
|
ENTRYPOINT ["dumb-init", "--", "/opt/app/entrypoint.sh"]
|