From a4c0ab91b27a42e2a2ec23f7c8629049bd6db6cd Mon Sep 17 00:00:00 2001 From: cheney Date: Sun, 5 Apr 2026 20:43:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29cfccf..dfc5be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# 使用官方Node.js 18镜像作为基础 -FROM node:18-alpine +# 构建阶段 +FROM node:18-alpine as builder # 设置工作目录 WORKDIR /app @@ -16,6 +16,20 @@ COPY . . # 构建项目 RUN npm run build +# 生产阶段 +FROM node:18-alpine + +# 设置工作目录 +WORKDIR /app + +# 复制必要的文件 +COPY --from=builder /app/package*.json ./ +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public + +# 安装生产依赖 +RUN npm install --only=production + # 暴露3000端口 EXPOSE 3000