# Frontend - Multi-stage optimized build
FROM node:22-alpine AS build
WORKDIR /app

# Copy package files for caching
COPY src/frontend/package*.json ./
RUN npm ci

# Copy source and build
COPY src/frontend/ .
RUN npm run build -- --configuration=production

# Nginx runtime
FROM nginx:alpine AS runtime
COPY --from=build /app/dist/student-enrollment/browser /usr/share/nginx/html
COPY deploy/docker/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s CMD wget -q --spider http://localhost/ || exit 1
