From 4f878340e60e5cabeed135abce77845934180df2 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Sun, 3 May 2026 08:43:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E5=8C=96=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 14 ++++++++++++++ Dockerfile | 31 +++++++++++++++++++++++++++++++ next.config.ts | 1 + package.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..761caca --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +.gitignore +.next +node_modules +.env* +!.env.example +.vscode +.DS_Store +README* +*.md +.serena +.sisyphus +.claude +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dcfe437 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# syntax=docker/dockerfile:1.7 +FROM node:25-alpine AS base +RUN npm install -g --force corepack@latest && corepack enable + +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile --prod=false + +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +ENV NEXT_TELEMETRY_DISABLED=1 +RUN pnpm build + +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production \ + NEXT_TELEMETRY_DISABLED=1 \ + PORT=3000 \ + HOSTNAME=:: +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 --ingroup nodejs nextjs +COPY --from=builder --chown=nextjs:nodejs /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +USER nextjs +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/next.config.ts b/next.config.ts index 9eb806a..d546a8d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,7 @@ import type { NextConfig } from "next" const nextConfig: NextConfig = { + output: "standalone", async rewrites() { // 仅在开发环境启用 API 代理 if (process.env.NODE_ENV !== "development") { diff --git a/package.json b/package.json index 522f71a..c221e7f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "juwan-frontend", "version": "0.1.0", "private": true, + "packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8", "scripts": { "dev": "next dev --turbopack", "build": "next build",