# Stage 1: Build the React Client # Use Node.js 20 as required by Vite and its dependencies FROM node:20-alpine AS client-builder WORKDIR /app/client COPY client/package*.json ./ RUN npm install COPY client/ . # Build for production RUN npm run build # Stage 2: Final Production Image # Use Python 3.9 for consistency with local dev setup FROM python:3.9-slim WORKDIR /app # Install Python dependencies COPY server/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the broker server code COPY server/main.py . # Copy built client static files from Stage 2 COPY --from=client-builder /app/client/dist /app/static # Expose Hugging Face Spaces port EXPOSE 7860 # Run the Uvicorn server, which will serve both the API broker and the static client. CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]