# Use an official Python runtime as a parent image FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 # Set the working directory in the container WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app # Install necessary system packages RUN apt-get update && apt-get install -y \ tesseract-ocr \ libtesseract-dev \ poppler-utils # Install Python dependencies RUN pip install \ fastapi \ uvicorn \ PyMuPDF \ torch torchvision\ tensorflow\ tf-keras\ flax\ pytesseract \ Pillow \ llama-index \ transformers # Create a non-root user RUN useradd -ms /bin/bash myuser # Create cache directory with appropriate permissions under user's home directory RUN mkdir -p /home/myuser/.cache/huggingface/hub && \ chown -R myuser /home/myuser/.cache # Switch to the non-root user USER myuser # Expose port 80 EXPOSE 80 # Command to run FastAPI using Uvicorn server CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]