Spaces:
Runtime error
Runtime error
| # Use an official Python image | |
| FROM python:3.9-slim | |
| # Set environment variables for cache location | |
| ENV HF_HOME="/app/cache" | |
| ENV TRANSFORMERS_CACHE="/app/cache" | |
| # Create the cache directory and set permissions | |
| RUN mkdir -p /app/cache && chmod -R 777 /app/cache | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy the requirements file first (to leverage Docker's layer caching) | |
| COPY requirements.txt /app/ | |
| # Install dependencies from requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY . /app | |
| # Ensure all files are accessible | |
| RUN chmod -R 777 /app | |
| # Pre-download the model (to avoid runtime downloading issues) | |
| RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32-multilingual-v1')" && chmod -R 777 /app/cache | |
| # Expose FastAPI port | |
| EXPOSE 7860 | |
| # Start FastAPI application | |
| CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |