FROM python:3.10.9 | |
# Set the working directory to /app | |
WORKDIR /app | |
# Create a directory for storing downloaded PDF files | |
RUN mkdir /app/downloads | |
# Create a non-root user | |
RUN useradd -m appuser | |
# Copy the current directory contents into the container at /app | |
COPY . /app | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
poppler-utils \ | |
tesseract-ocr | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
# Change ownership of the app directory to the non-root user | |
RUN chown -R appuser:appuser /app | |
# Switch to the non-root user | |
USER appuser | |
# Set the nltk_data directory path | |
ENV NLTK_DATA /app/nltk_data | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |