Procházet zdrojové kódy

perf(docker): BuildKit 缓存加速构建 + fix: 模型列表改用 enabled 接口

Dockerfile 添加 --mount=type=cache 持久化 bun/go 缓存,
前端改代码时跳过后端构建(~10s),后端改代码时跳过前端(~30s)。
模型限流下拉改用 /api/channel/models_enabled 只返回已启用模型。
master
fengsilin před 3 týdny
rodič
revize
155aa12014
2 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. +5
    -3
      Dockerfile
  2. +2
    -2
      web/src/components/table/users/modals/UserModelRateLimitSection.jsx

+ 5
- 3
Dockerfile Zobrazit soubor

@@ -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



+ 2
- 2
web/src/components/table/users/modals/UserModelRateLimitSection.jsx Zobrazit soubor

@@ -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


Načítá se…
Zrušit
Uložit