Spaces:
Sleeping
Sleeping
File size: 1,275 Bytes
459923e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# Hugging Face Spaces Dockerfile
# Based on the official HF Spaces documentation
FROM python:3.10-slim
# Create a non-root user for security
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Install system dependencies for OCR and PDF processing
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
# 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 .
# Create necessary directories
RUN mkdir -p temp output
# 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"] |