refactor(build): enable standalone next.js build and fix rag-server Dockerfile paths

This commit is contained in:
Haitao Pan 2025-12-04 21:40:58 +08:00
parent b059fbd265
commit 9aef9281fe
4 changed files with 723 additions and 709 deletions

View File

@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts";
import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@ -5,6 +5,13 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const nextConfig = {
// ===============================
// 🚀 生产优化 —— 最关键的三行
// ===============================
output: "standalone", // 让 Next.js 生成可独立运行的最小产物(大幅减小 Docker 镜像)
swcMinify: true, // 使用 Rust 压缩器(比 Terser 快 ~20x
compress: true, // Gzip 压缩输出(确保小体积网络传输)
// 配置允许的外部图片域名
images: {
remotePatterns: [

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,33 @@
# Multi-stage production build for the RAG server
# =======================================================
# Stage 1 — Builder
# =======================================================
ARG GO_RUNTIME_IMAGE
FROM ${GO_RUNTIME_IMAGE} AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/xcontrol-rag ./rag-server/cmd/xcontrol-server
# =======================================================
# Stage 2 — Runtime
# =======================================================
ARG GO_RUNTIME_IMAGE
FROM ${GO_RUNTIME_IMAGE} AS runtime
ENV CONFIG_PATH=/etc/xcontrol/rag-server.yaml PORT=8090
ENV CONFIG_PATH=/etc/xcontrol/rag-server.yaml \
PORT=8090
# ---- Install minimal dependencies for runtime ----------------
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /out/xcontrol-rag /usr/local/bin/rag-server
COPY rag-server/config/server.yaml /etc/xcontrol/rag-server.yaml
COPY --from=builder /out/rag-server /usr/local/bin/rag-server
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
VOLUME ["/etc/xcontrol/"]