# Use a lightweight Python base image FROM python:3.10-slim # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ pkg-config \ libsystemd-dev \ libcairo2-dev \ tesseract-ocr \ libglib2.0-0 \ libsm6 \ libxrender1 \ libxext6 \ poppler-utils \ gettext \ && rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy only dependency files first for better caching COPY requirements.txt . # Install pip and dependencies RUN pip install --upgrade pip \ && pip install torch==2.6.0 --no-cache-dir \ && pip install -r requirements.txt --no-cache-dir # Copy rest of your code (this is after deps so doesn't bust cache) COPY . . # Expose port 7860 (required by HF Spaces) EXPOSE 7860 # Run the Flask app CMD ["python", "-m", "ai_med_extract", "--port=7860", "--host=0.0.0.0"]