Spaces:
Runtime error
Runtime error
Create Dockerfile
Browse files- Dockerfile +43 -0
Dockerfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as the base image
|
| 2 |
+
FROM python:3.8-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies for pdfplumber, pytesseract, and general compatibility
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
tesseract-ocr \
|
| 10 |
+
libtesseract-dev \
|
| 11 |
+
poppler-utils \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# Copy application code
|
| 15 |
+
COPY . /app
|
| 16 |
+
|
| 17 |
+
# Install Python dependencies, including sentencepiece for Pegasus
|
| 18 |
+
RUN pip install --no-cache-dir \
|
| 19 |
+
flask \
|
| 20 |
+
flask-cors \
|
| 21 |
+
pdfplumber \
|
| 22 |
+
pillow \
|
| 23 |
+
pytesseract \
|
| 24 |
+
numpy \
|
| 25 |
+
torch \
|
| 26 |
+
transformers \
|
| 27 |
+
datasets \
|
| 28 |
+
scikit-learn \
|
| 29 |
+
gunicorn \
|
| 30 |
+
sentencepiece
|
| 31 |
+
|
| 32 |
+
# Create uploads and cache directories with proper permissions
|
| 33 |
+
RUN mkdir -p /app/uploads /app/cache && \
|
| 34 |
+
chmod -R 777 /app/uploads /app/cache
|
| 35 |
+
|
| 36 |
+
# Set environment variable for Hugging Face cache (using HF_HOME as per latest transformers recommendation)
|
| 37 |
+
ENV HF_HOME=/app/cache
|
| 38 |
+
|
| 39 |
+
# Expose port (Hugging Face Spaces typically uses 7860, but we'll stick to 5000 and adjust in app.py if needed)
|
| 40 |
+
EXPOSE 5000
|
| 41 |
+
|
| 42 |
+
# Run with Gunicorn
|
| 43 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
|