优化 dockerfile
Some checks failed
Docker Build and Push / build-image (push) Failing after 6m42s

This commit is contained in:
cheney 2026-04-05 20:43:32 +08:00
parent 697b625f4c
commit a4c0ab91b2

View File

@ -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