Spaces:
Sleeping
Sleeping
File size: 1,955 Bytes
0b96209 2cf117f f1199d3 b328f90 e670b79 b328f90 55b2cb1 f1199d3 55b2cb1 2cf117f 1c943af 0b96209 d2aff2a f1199d3 b328f90 f1199d3 e670b79 5057a68 d2a35a3 e670b79 f1199d3 e670b79 f1199d3 e670b79 f1199d3 e670b79 5057a68 e670b79 f1199d3 0b96209 f1199d3 2cf117f 1c943af 2cf117f f1199d3 1c943af 89b8ede |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git gcc g++ libglib2.0-0 libsm6 libxext6 libxrender-dev \
build-essential curl && \
rm -rf /var/lib/apt/lists/*
# Create user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Copy requirements first for better caching
COPY --chown=user requirements.txt ./
# Install dependencies with proper NumPy version
RUN pip install --upgrade pip && \
pip install --no-cache-dir packaging ninja wheel setuptools
# Force install NumPy 1.x first to avoid compatibility issues
RUN pip install --no-cache-dir --force-reinstall "numpy<2.0"
# Install PyTorch CPU version (compatible with NumPy 1.x)
RUN pip install --no-cache-dir torch==2.2.2+cpu torchvision==0.17.2+cpu torchaudio==2.2.2+cpu \
--index-url https://download.pytorch.org/whl/cpu
# Install transformers and related packages
RUN pip install --no-cache-dir \
"transformers>=4.37.0" \
datasets \
Pillow \
accelerate \
scipy
# Install FastAPI and related packages
RUN pip install --no-cache-dir \
fastapi \
"uvicorn[standard]" \
python-multipart
# Install other dependencies (skip problematic ones)
RUN pip install --no-cache-dir \
opencv-python-headless
# Try to install qwen-vl-utils (if it fails, continue)
RUN pip install --no-cache-dir qwen-vl-utils || echo "qwen-vl-utils installation failed, continuing..."
# Copy all application files
COPY --chown=user . .
# Set environment variables for better compatibility
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV HF_HOME=/tmp/hf_home
ENV PYTHONUNBUFFERED=1
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "120"] |