# 前端构建
ARG NODE_IMAGE=node:20-alpine

FROM ${NODE_IMAGE} AS builder
WORKDIR /build

COPY package.json package-lock.json* ./
RUN npm install

COPY . ./
RUN npm run build

# 使用 nginx 提供静态资源
FROM nginx:1.29.0-alpine
COPY --from=builder /build/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
