# --- Stage 1: Build the React Frontend --- FROM node:18-slim AS frontend-builder WORKDIR /build COPY stock-scout-dashboard/package*.json ./ RUN npm install COPY stock-scout-dashboard/ ./ RUN npm run build # --- Stage 2: Setup the Python Backend & Serve --- FROM python:3.11 WORKDIR /app # Install system dependencies for ML libraries and Postgres RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ gcc \ && rm -rf /var/lib/apt/lists/* # Copy backend requirements and install COPY backend/requirements.txt . RUN pip install --no-cache-dir --upgrade pip setuptools wheel RUN pip install --no-cache-dir -r requirements.txt # Copy backend code COPY backend/ ./backend/ # Copy built frontend from Stage 1 into the backend's static folder COPY --from=frontend-builder /build/dist ./backend/static/ # Environment variables for Hugging Face Spaces ENV PORT=7860 EXPOSE 7860 # Command to run the application # We use uvicorn to serve the FastAPI app on the port required by Hugging Face CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]