FROM python:3.10-slim # Prevent pip from caching downloaded packages ARG PIP_NO_CACHE_DIR=1 # Install system dependencies RUN apt-get update && apt-get install -y \ tesseract-ocr \ libgl1 \ gcc \ g++ \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ && rm -rf /var/lib/apt/lists/* # Install Python packages RUN pip install --no-cache-dir numpy RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu RUN pip install --no-cache-dir paddlepaddle -i https://pypi.org/simple RUN pip install --no-cache-dir opencv-python-headless RUN pip install --no-cache-dir \ transformers \ pytesseract \ gradio \ Pillow \ paddleocr \ pydantic \ fastapi # Create a non-root user RUN useradd -m -u 1000 user USER user ENV HOME=/home/user WORKDIR $HOME/app # Copy application files COPY --chown=user . $HOME/app # Run the application CMD ["python", "app.py"]