# ---- stage 1: build ----
FROM node:22-alpine AS build
WORKDIR /app

# Install deps (cache layer)
COPY package.json package-lock.json* ./
RUN npm ci

# Copy source and build
COPY tsconfig.json vite.config.ts index.html ./
COPY src/ src/
RUN npm run build

# ---- stage 2: serve ----
FROM nginx:alpine-slim AS serve
COPY --from=build /app/dist /usr/share/nginx/html

# Optional: custom nginx config for caching / security
COPY nginx.default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
