FROM python:3.12-slim AS builder WORKDIR /app # Install system dependencies needed for pymupdf and psycopg2 RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ gcc \ libpq-dev \ && rm -rf /var/lib/apt/lists/* # Copy and install Python dependencies COPY backend/requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # ───────────────────────────────────────────────────────────────────── FROM python:3.12-slim WORKDIR /app # Copy only runtime system deps (pymupdf needs libgl, libglib) and curl for healthcheck RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ libpq5 \ curl \ && rm -rf /var/lib/apt/lists/* # Copy Python packages from builder COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages COPY --from=builder /usr/local/bin /usr/local/bin # Copy application code COPY backend/ . # Create directories for uploads and fastembed cache RUN mkdir -p /app/uploads /app/fastembed_cache # Expose the application port EXPOSE 8000 # Run the FastAPI application with uvicorn # Uses UVICORN_WORKERS environment variable (defaults to 4) for production concurrency CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]