Spaces:
Sleeping
Sleeping
File size: 1,142 Bytes
c49ad09 5edd3f0 c49ad09 5f4c13a c49ad09 |
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 |
FROM python:3.10-slim
# 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
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
COPY --chown=user ./ $HOME/app
RUN pip install -r requirements.txt
CMD fastapi run --reload --host=0.0.0.0 --port=7860 |