From 155aa1201445038b4e0bbf273704bcb68c1cec1b Mon Sep 17 00:00:00 2001 From: fengsilin Date: Thu, 14 May 2026 17:57:04 +0800 Subject: [PATCH] =?UTF-8?q?perf(docker):=20BuildKit=20=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E6=9E=84=E5=BB=BA=20+=20fix:=20=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=88=97=E8=A1=A8=E6=94=B9=E7=94=A8=20enabled=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile 添加 --mount=type=cache 持久化 bun/go 缓存, 前端改代码时跳过后端构建(~10s),后端改代码时跳过前端(~30s)。 模型限流下拉改用 /api/channel/models_enabled 只返回已启用模型。 --- Dockerfile | 8 +++++--- .../table/users/modals/UserModelRateLimitSection.jsx | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd1ac58..7019a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + FROM oven/bun:latest AS builder # 使用淘宝镜像加速 @@ -6,7 +8,7 @@ ENV BUN_INSTALL_REGISTRY=https://registry.npmmirror.com WORKDIR /build COPY web/package.json . COPY web/bun.lock . -RUN bun install +RUN --mount=type=cache,target=/root/.bun/install/cache bun install COPY ./web . COPY ./VERSION . RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build @@ -22,11 +24,11 @@ ENV GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} WORKDIR /build ADD go.mod go.sum ./ -RUN go mod download +RUN --mount=type=cache,target=/go/pkg/mod go mod download COPY . . COPY --from=builder /build/dist ./web/dist -RUN go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api +RUN --mount=type=cache,target=/root/.cache/go-build go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api FROM debian:bookworm-slim diff --git a/web/src/components/table/users/modals/UserModelRateLimitSection.jsx b/web/src/components/table/users/modals/UserModelRateLimitSection.jsx index fe81b33..727c49b 100644 --- a/web/src/components/table/users/modals/UserModelRateLimitSection.jsx +++ b/web/src/components/table/users/modals/UserModelRateLimitSection.jsx @@ -46,10 +46,10 @@ const UserModelRateLimitSection = ({ userId }) => { useEffect(() => { const loadModels = async () => { try { - const res = await API.get('/api/channel/models'); + const res = await API.get('/api/channel/models_enabled'); const { success, data } = res.data; if (success && Array.isArray(data)) { - setModelOptions(data.map((m) => ({ label: m.id, value: m.id }))); + setModelOptions(data.map((m) => ({ label: m, value: m }))); } } catch (e) { // ignore