Spaces:
Sleeping
Sleeping
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 |