iboard/Dockerfile
cheney 092e763a05
Some checks failed
Docker Build and Push / build-image (push) Failing after 18m33s
优化 dockerfile
2026-04-05 21:01:12 +08:00

38 lines
786 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 构建阶段
FROM node:18-alpine AS builder
# 设置工作目录
WORKDIR /app
# 复制package.json和package-lock.json
COPY package*.json ./
# 设置淘宝源并安装依赖
RUN npm config set registry https://registry.npmmirror.com && npm install
# 复制项目文件
COPY . .
# 构建项目
RUN npm run build
# 生产阶段
FROM node:18-alpine
# 设置工作目录
WORKDIR /app
# 复制必要的文件
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/.next ./.next
# 复制public目录如果存在
COPY --from=builder /app/public* ./public/
# 设置淘宝源并安装生产依赖
RUN npm config set registry https://registry.npmmirror.com && npm install --only=production
# 暴露3000端口
EXPOSE 3000
# 启动生产服务器
CMD ["npm", "start"]