# ── build stage: compile the Vite bundle inside Docker ──
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# VITE_UDYAM_API_BASE_URL is unset here, so the compiled-in default
# (http://udyamlinc-backend.lincpay/api/v1/udyam) is baked into the bundle.
RUN npm run build

# ── serve stage: nginx serving the static SPA on 5173 ──
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 5173
