File size: 1,573 Bytes
539fd5b
4a1a141
539fd5b
 
 
 
 
 
 
4756959
539fd5b
 
 
4756959
539fd5b
4756959
539fd5b
 
 
4756959
539fd5b
4756959
539fd5b
4756959
539fd5b
 
4756959
539fd5b
 
4756959
539fd5b
 
4756959
539fd5b
 
 
 
 
 
bf65784
539fd5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
    libpng-dev \
    libjpeg-dev \
    zlib1g-dev \
    tesseract-ocr \
    libtesseract-dev \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

COPY --chown=user:user requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

COPY --chown=user:user . /app

EXPOSE 7860

# Increase timeout and reduce workers
CMD ["gunicorn", "--workers", "1", "--timeout", "600", "--bind", "0.0.0.0:7860", "app:app"]

# # Use an official Python runtime as the base image
# FROM python:3.8-slim

# # Set working directory
# WORKDIR /app

# # Install system dependencies
# RUN apt-get update && apt-get install -y \
#     tesseract-ocr \
#     libtesseract-dev \
#     poppler-utils \
#     && rm -rf /var/lib/apt/lists/*

# # Copy application code
# COPY . /app

# # Install Python dependencies
# RUN pip install --no-cache-dir \
#     flask \
#     flask-cors \
#     pdfplumber \
#     pillow \
#     pytesseract \
#     numpy \
#     torch \
#     transformers \
#     datasets \
#     scikit-learn \
#     gunicorn

# # Create uploads and cache directories with proper permissions
# RUN mkdir -p /app/uploads /app/cache && \
#     chmod -R 777 /app/uploads /app/cache

# # Set environment variable for Hugging Face cache
# ENV TRANSFORMERS_CACHE=/app/cache

# # Expose port
# EXPOSE 5000

# # Run with Gunicorn
# CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]