davidtran999's picture
Upload Dockerfile with huggingface_hub
ee0c705 verified
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PORT=7860
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-vie \
libpoppler-cpp-dev \
pkg-config \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
COPY backend/requirements.txt /app/requirements.txt
# Install CPU-only torch first (much smaller, no CUDA dependencies)
# This avoids downloading 2GB+ of CUDA packages on CPU-only environments
# CRITICAL: Install transformers>=4.50.0 BEFORE other packages to avoid conflicts
# Remove transformers from requirements.txt temporarily to avoid conflicts
RUN sed -i '/^transformers/d' /app/requirements.txt && \
pip install --upgrade pip && \
pip install --no-cache-dir torch==2.0.0 --index-url https://download.pytorch.org/whl/cpu && \
pip uninstall -y transformers sentence-transformers peft || true && \
pip install --no-cache-dir --upgrade --force-reinstall \
"transformers>=4.50.0,<5.0.0" \
"sentence-transformers>=2.2.0" \
"FlagEmbedding>=1.2.0" && \
pip install --no-cache-dir -r requirements.txt && \
pip show transformers | grep Version && \
python3 -c "import transformers; print(f'[VERIFY] transformers version: {transformers.__version__}')"
COPY backend /app
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]