Spaces:
Sleeping
Sleeping
| FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Create cache directory for models | |
| RUN mkdir -p /app/cache | |
| # Pre-download the model during build | |
| RUN python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('BAAI/bge-large-en-v1.5', cache_folder='/app/cache'); print('Model downloaded successfully')" | |
| # Set environment variables | |
| ENV TRANSFORMERS_CACHE=/app/cache | |
| ENV SENTENCE_TRANSFORMERS_HOME=/app/cache | |
| ENV HF_HOME=/app/cache | |
| ENV CUDA_VISIBLE_DEVICES=0 | |
| # Expose port | |
| EXPOSE 7860 | |
| # Run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |