Spaces:
Runtime error
Runtime error
File size: 1,366 Bytes
d8763b8 50783df f2d9963 7913d8b f2d9963 553ae3d decd04d 7913d8b f2d9963 d8763b8 90a3d0b f2d9963 d8763b8 50783df f2d9963 97d327d |
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 |
FROM python:3.9
# Switch to root for system installations
USER root
# Install Tesseract and language data
RUN apt-get update && apt-get install -y \
tesseract-ocr \
tesseract-ocr-eng \
&& rm -rf /var/lib/apt/lists/*
# Find tessdata directory and set permissions
RUN tessdata_dir=$(find /usr -name "tessdata" -type d | grep "tesseract") && \
echo "Found tessdata at: $tessdata_dir" && \
mkdir -p /usr/share/tesseract-ocr/4.00/tessdata && \
cp -r $tessdata_dir/* /usr/share/tesseract-ocr/4.00/tessdata/ && \
chmod -R 755 /usr/share/tesseract-ocr && \
chown -R root:root /usr/share/tesseract-ocr
# Set environment variable for Tesseract
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata/
# Verify tessdata files are present
RUN ls -la $TESSDATA_PREFIX
# Create user and set up environment
RUN useradd -m -u 1000 user && \
chown -R user:user /usr/share/tesseract-ocr/4.00/tessdata
RUN --mount=type=secret,id=Access_key,mode=0444,required=true \
git clone $(cat /run/secrets/Access_key) /app
WORKDIR /app
# Switch to user for pip installations
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy application files
CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "300", "--workers", "2", "--threads", "4", "app:app"]
|