# 1. 第一阶段：构建
FROM node:20-alpine AS builder

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

# 2. 根据 MODE 参数执行对应的打包命令
RUN npm run build

# 2. 第二阶段：部署
FROM nginx:stable-alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d/default.conf