FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
    curl \
    tesseract-ocr \
    libtesseract-dev \
    libleptonica-dev \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

# tesserocr doesn't reliably auto-discover Debian's tessdata location -
# confirmed for real: "Failed to init API, possibly an invalid tessdata
# path: ./" without this set explicitly.
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

RUN mkdir -p /app/uploads /app/outputs

EXPOSE 8080

CMD ["python", "app/main.py"]
