| FROM python:3.12-slim-bookworm | |
| # Install system dependencies for Docling, graphics rendering, OCR, and ColPali | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgomp1 \ | |
| tesseract-ocr \ | |
| libopencv-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the application files | |
| COPY server/ /fastAPI/ | |
| COPY assets/ /streamlit/assets/ | |
| COPY app.py /streamlit/app.py | |
| COPY server/logger.py /streamlit/logger.py | |
| # Copy streamlit config directory (create if it doesn't exist) | |
| RUN mkdir -p /streamlit/.streamlit | |
| COPY .streamlit/ /streamlit/.streamlit/ | |
| # Copy requirements | |
| COPY requirements.txt /temp_files/requirements.txt | |
| # Add entry point script | |
| COPY entrypoint.sh /entrypoint.sh | |
| # Create a non-root user and group | |
| RUN useradd -m appuser | |
| # Set permissions so appuser owns what it needs | |
| RUN chmod +x /entrypoint.sh && \ | |
| chown -R appuser:appuser /fastAPI /streamlit /temp_files /entrypoint.sh /tmp | |
| # Switch to non-root user | |
| USER appuser | |
| WORKDIR /temp_files | |
| ENV PATH="/home/appuser/.local/bin:${PATH}" | |
| # Install dependencies: | |
| RUN python -m pip install --upgrade pip | |
| RUN pip install --no-cache-dir --prefer-binary -r requirements.txt | |
| # Switch back to root briefly to clean up temp files | |
| WORKDIR /fastAPI | |
| USER root | |
| RUN rm -rf /temp_files && pip cache purge | |
| USER appuser | |
| # EXPOSE PORTS | |
| # dev -> EXPOSE 8000, 8501, 11434 | |
| # deploy -> EXPOSE 7860 | |
| # Start entrypoint | |
| CMD ["/entrypoint.sh"] |