FROM node:20 AS builder

WORKDIR /app

COPY package*.json ./
RUN npm config set registry https://registry.npmmirror.com
RUN npm install

COPY . .

ARG ENV=production
ENV NODE_ENV=$ENV
ENV VITE_APP_ENV=$ENV

RUN npm run build:dev

FROM nginx:alpine

COPY --from=builder /app/dist /usr/share/nginx/html

COPY nginx.conf /etc/nginx/conf.d/default.conf


# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]