# 构建阶段
FROM node:20-alpine AS build
WORKDIR /app

# 配置 npm 镜像加速
RUN npm config set registry https://registry.npmmirror.com

COPY package*.json ./
RUN rm -f package-lock.json && npm install --legacy-peer-deps

COPY . .
RUN npm run build

# 生产阶段
FROM nginx:alpine
COPY --from=build /wwwroot /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
