# Stage 1: Build
FROM node:20-alpine AS builder

WORKDIR /app
RUN npm config set registry https://registry.npmmirror.com
COPY package*.json ./
RUN npm install --no-audit --no-fund --package-lock=false
COPY . .

ARG VITE_AI_API_BASE_URL=
ENV VITE_AI_API_BASE_URL=$VITE_AI_API_BASE_URL

RUN npm run build

# Stage 2: Serve
FROM nginx:alpine

COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
