From 93688a0e4e5b771d10e18e5a913060dfd9ab3673 Mon Sep 17 00:00:00 2001 From: tone Date: Sat, 20 Dec 2025 22:01:51 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/.dockerignore | 4 ++++ apps/frontend/Dockerfile | 45 ++++++++++++++++++++---------------- apps/frontend/next.config.ts | 3 ++- 3 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 apps/.dockerignore diff --git a/apps/.dockerignore b/apps/.dockerignore new file mode 100644 index 0000000..b97feae --- /dev/null +++ b/apps/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.next +.git +.env.local \ No newline at end of file diff --git a/apps/frontend/Dockerfile b/apps/frontend/Dockerfile index 8ccfa56..d7b607d 100644 --- a/apps/frontend/Dockerfile +++ b/apps/frontend/Dockerfile @@ -1,28 +1,33 @@ -FROM node:22-alpine AS builder - -RUN npm install -g pnpm - -WORKDIR /app -COPY package*.json pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile -COPY . . - -ARG API_BASE -ENV API_BASE=$API_BASE - -RUN pnpm run build - -FROM node:22-alpine +# 安装依赖 +FROM node:22-alpine AS deps +RUN apk add --no-cache libc6-compat RUN npm install -g pnpm WORKDIR /app COPY package.json pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile --prod -COPY --from=builder /app/.next ./.next -COPY --from=builder /app/public ./public -COPY --from=builder /app/next.config.ts ./ +RUN pnpm install --frozen-lockfile +# 编译 +FROM node:22-alpine AS builder +RUN npm install -g pnpm +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +ARG API_BASE +ENV API_BASE=$API_BASE +RUN pnpm run build + +# 运行 +FROM node:22-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production ARG API_BASE ENV API_BASE=$API_BASE +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public + EXPOSE 3000 -CMD ["pnpm", "start"] \ No newline at end of file + +CMD ["node", "server.js"] \ No newline at end of file diff --git a/apps/frontend/next.config.ts b/apps/frontend/next.config.ts index 056d978..5d35687 100644 --- a/apps/frontend/next.config.ts +++ b/apps/frontend/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: 'standalone', reactStrictMode: true, devIndicators: { position: 'bottom-right', @@ -16,7 +17,7 @@ const nextConfig: NextConfig = { }, images: { remotePatterns: [new URL('https://tone-personal.oss-cn-chengdu.aliyuncs.com/**')] - } + }, }; export default nextConfig;