File size: 1,123 Bytes
8d66792
b76793f
 
 
 
d9ba4a9
b76793f
3a57d82
b76793f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b267a19
 
 
 
 
 
b76793f
 
 
 
 
 
 
 
 
8607b18
 
 
 
 
b267a19
d9ba4a9
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
# Use official Python runtime as a parent image
FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    tesseract-ocr \
    tesseract-ocr-eng \
    tesseract-ocr-deu \
    tesseract-ocr-fra \
    tesseract-ocr-spa \
    tesseract-ocr-por \
    tesseract-ocr-ita \
    tesseract-ocr-rus \
    tesseract-ocr-chi-sim \
    tesseract-ocr-jpn \
    tesseract-ocr-kor \
    poppler-utils \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Fix: Ensure logs appear immediately in the console
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
ENV HF_HOME=/tmp/cache
ENV PORT=7860

COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel \
    && pip install --default-timeout=100 --retries=10 --no-cache-dir -r requirements.txt

COPY . .

RUN useradd -m appuser && chown -R appuser /app
USER appuser

RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME}

EXPOSE $PORT

CMD bash -c "\
(while true; do curl -s https://xce009-ocr-api.hf.space >/dev/null; sleep 300; done) & \
uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 4"