# ---- Build stage: compile the Vite/React app into static files ----
FROM node:22-bookworm AS build
WORKDIR /app

# Install dependencies from the lockfile (reproducible)
COPY package.json package-lock.json ./
RUN npm ci

# Copy the rest of the source and build (outputs to /app/dist)
COPY . .
RUN npm run build

# ---- Serve stage: tiny nginx image that serves the built files ----
FROM nginx:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
