# ──────────────────────────────────────────────────────────── # NeuralVault 2.0 - Unified Multi-Stage Production Dockerfile # Ready for Hugging Face Spaces (Docker Space) or Render/Fly.io # ──────────────────────────────────────────────────────────── # --- STAGE 1: Build React Frontend --- FROM node:18-slim AS frontend-builder WORKDIR /app/frontend # Configure production build settings to prevent OOM and bypass ESLint compatibility issues ENV NODE_ENV=production ENV DISABLE_ESLINT_PLUGIN=true ENV NODE_OPTIONS="--max-old-space-size=4096" # Copy dependencies first for caching layers COPY frontend/package*.json ./ RUN npm install --legacy-peer-deps --include=dev # Copy frontend source and compile React production bundle COPY frontend/ ./ RUN npm run build # --- STAGE 2: Serve FastAPI Backend & Static React Assets --- FROM python:3.11-slim WORKDIR /app # Install system dependencies (needed for certain lock/math packages) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy backend requirements first and install dependencies COPY backend/requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt # Copy backend codebase COPY backend/ ./ # Inject compiled React assets directly into FastAPI's static folder COPY --from=frontend-builder /app/frontend/build ./static # Expose port 8000 EXPOSE 8000 # Start FastAPI server CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]