# Stage 1: Build the Vite SPA FROM node:20-slim AS builder WORKDIR /app # Install pnpm RUN npm install -g pnpm@10 # Copy package files first for layer caching COPY package.json pnpm-lock.yaml ./ # Install all dependencies (including devDependencies for build) RUN pnpm install --frozen-lockfile # Copy source code COPY . . # Build the frontend with the backend URL pointing to localhost:8080 ARG VITE_LANGGRAPH_URL=http://localhost:8080 ENV VITE_LANGGRAPH_URL=${VITE_LANGGRAPH_URL} RUN pnpm build # Stage 2: Serve with nginx FROM nginx:alpine # Copy built assets COPY --from=builder /app/dist /usr/share/nginx/html # Copy nginx config for SPA routing COPY nginx.frontend.conf /etc/nginx/conf.d/default.conf EXPOSE 3000 CMD ["nginx", "-g", "daemon off;"]