File size: 1,316 Bytes
96c003e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
# Use a minimal Python base image
FROM python:3.10-slim

# Install system dependencies including libcrypt and additional libraries for PyMuPDF
RUN apt-get update && \
    apt-get install -y \
    libcrypt1 \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    libgomp1 \
    poppler-utils \
    build-essential \
    libfontconfig1 \
    libxrender1 \
    libxtst6 \
    libxi6 \
    libfreetype6-dev \
    libjpeg-dev \
    libopenjp2-7-dev \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .

# Upgrade pip and install Python dependencies with verbose output
RUN pip install --upgrade pip

# Install PyMuPDF first to check for issues early
RUN pip install --no-cache-dir PyMuPDF==1.23.0

# Test PyMuPDF import
RUN python -c "import fitz; print('PyMuPDF imported successfully')"

# Install remaining dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Verify python-docx installation
RUN python -c "from docx import Document; print('python-docx installed successfully')"

# Copy source code to container
COPY . .

# Expose the port Flask will run on (important for Hugging Face)
EXPOSE 7860

# Run the Flask app
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]