ocr / Dockerfile
Hanz Pillerva
new up
486ed05
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgl1 \
libgomp1 \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements and install Python dependencies
COPY requirements.txt .
# Install CPU-only torch first to avoid downloading the huge CUDA build (~2GB)
RUN pip install --no-cache-dir \
torch \
torchvision \
--index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir \
flask \
flask-cors \
numpy \
opencv-python-headless \
Pillow \
transformers \
sentencepiece \
pymysql \
python-dotenv \
spacy \
scikit-learn
# Copy app files
COPY . .
# HuggingFace Spaces requires port 7860
EXPOSE 7860
# Flush stdout immediately so logs appear in HuggingFace Spaces
ENV PYTHONUNBUFFERED=1
CMD ["python", "-u", "app.py"]