mirror of
https://github.com/2930134478/AI-CS.git
synced 2026-06-15 00:44:30 +08:00
docker新增ts部署
This commit is contained in:
+5
-4
@@ -38,11 +38,12 @@ ENV NODE_ENV=production
|
||||
# 复制 package 文件(用于安装生产依赖)
|
||||
COPY package*.json ./
|
||||
|
||||
# 只安装生产依赖(生产环境使用 next.config.mjs,无需 TypeScript)
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
# 安装生产依赖 + TypeScript(next start 加载 next.config.ts 需要 TS,必须在构建时装好,避免运行时安装)
|
||||
RUN npm ci --only=production && npm install typescript --no-save && npm cache clean --force
|
||||
|
||||
# 从构建阶段复制必要的文件(使用 .mjs 配置,避免 next start 时加载 next.config.ts 触发安装 TypeScript)
|
||||
COPY --from=builder /app/next.config.mjs ./
|
||||
# 从构建阶段复制必要的文件
|
||||
COPY --from=builder /app/next.config.ts ./
|
||||
COPY --from=builder /app/tsconfig.json ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next ./.next
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* 生产用 Next 配置(纯 JS,运行时无需 TypeScript)
|
||||
* 与 next.config.ts 逻辑一致,供 Docker 生产镜像使用
|
||||
*/
|
||||
|
||||
const backendPort = process.env.NEXT_PUBLIC_BACKEND_PORT || "8080";
|
||||
const backendHost = process.env.NEXT_PUBLIC_BACKEND_HOST || "localhost";
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
async rewrites() {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
return [
|
||||
{
|
||||
source: "/agent/profile/:path*",
|
||||
destination: `http://${backendHost}:${backendPort}/agent/profile/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/agent/avatar/:path*",
|
||||
destination: `http://${backendHost}:${backendPort}/agent/avatar/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/agent/embedding-config",
|
||||
destination: `http://${backendHost}:${backendPort}/agent/embedding-config`,
|
||||
},
|
||||
{
|
||||
source: "/agent/ai-config/:path*",
|
||||
destination: `http://${backendHost}:${backendPort}/agent/ai-config/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/:path((?!_next|agent|chat|favicon.ico).*)",
|
||||
destination: `http://${backendHost}:${backendPort}/:path*`,
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
protocol: "http",
|
||||
hostname: "192.168.124.9",
|
||||
port: backendPort,
|
||||
pathname: "/uploads/**",
|
||||
},
|
||||
{
|
||||
protocol: "http",
|
||||
hostname: "localhost",
|
||||
port: backendPort,
|
||||
pathname: "/uploads/**",
|
||||
},
|
||||
{
|
||||
protocol: "http",
|
||||
hostname: "127.0.0.1",
|
||||
port: backendPort,
|
||||
pathname: "/uploads/**",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
Reference in New Issue
Block a user