Spaces:
Sleeping
Sleeping
# Hugging Face Spaces Dockerfile | |
# Based on the official HF Spaces documentation | |
FROM python:3.10-slim | |
WORKDIR /app | |
# Install system dependencies for OCR and PDF processing as root | |
RUN apt-get update && apt-get install -y \ | |
poppler-utils \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
libsm6 \ | |
libxext6 \ | |
libxrender1 \ | |
libffi-dev \ | |
build-essential \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& apt-get clean | |
# Create a non-root user for security | |
RUN useradd -m -u 1000 user | |
# Create necessary directories as root and set proper ownership | |
RUN mkdir -p temp output && \ | |
chown -R user:user /app | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Copy requirements first for better caching | |
COPY --chown=user requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir --user -r requirements.txt | |
# Copy application files | |
COPY --chown=user app.py . | |
COPY --chown=user OCR.py . | |
COPY --chown=user Feedback.py . | |
COPY --chown=user PDFFeedbackGenerator.py . | |
COPY --chown=user OCRAccuracyAnalyzer.py . | |
# Set environment variables | |
ENV POPPLER_PATH=/usr/bin | |
ENV PYTHONPATH=/app | |
ENV PYTHONUNBUFFERED=1 | |
# Expose port 7860 for Hugging Face Spaces | |
EXPOSE 7860 | |
# Start the application on port 7860 | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |