# Step 1: Build React (Vite) app
FROM node:22 AS build
WORKDIR /app

# Copy package files
COPY package*.json ./

# Clean install
RUN npm ci --legacy-peer-deps

# Copy source files
COPY . .

ENV NODE_ENV=production
# Skip Orval - use pre-generated files committed to git
ENV SKIP_ORVAL=true

# Build the app
RUN npm run build

# Step 2: Nginx runtime
FROM nginx:1.27-alpine
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]