# Use a slim Python image FROM python:3.10-slim # Install system dependencies including Node.js for the frontend build RUN apt-get update && apt-get install -y \ build-essential \ libmagic1 \ poppler-utils \ tesseract-ocr \ libgl1 \ libglib2.0-0 \ curl \ && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y nodejs \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user WORKDIR /app # Copy the whole project first for the build COPY --chown=user . . # ── Frontend Build ── # WORKDIR /app/frontend-app RUN npm install RUN npm run build # ── Backend Setup ── # WORKDIR /app RUN pip install --no-cache-dir --upgrade -r requirements.txt RUN pip install --no-cache-dir python-multipart # ── Playwright (PDF report rendering) ── # RUN python -m playwright install-deps chromium RUN python -m playwright install chromium # Create necessary directories and set permissions RUN mkdir -p /app/reports /app/data/vectors /app/uploads && \ chown -R user:user /app USER user ENV PATH="/home/user/.local/bin:$PATH" RUN python -m playwright install chromium # Hugging Face Spaces run on port 7860 EXPOSE 7860 # Serve the application CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]