| # Use official Python image | |
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set cache directories to avoid permission issues | |
| ENV TRANSFORMERS_CACHE=/tmp/transformers_cache | |
| ENV HF_HOME=/tmp/hf_home | |
| ENV HF_DATASETS_CACHE=/tmp/hf_datasets_cache | |
| ENV HF_METRICS_CACHE=/tmp/hf_metrics_cache | |
| # Copy requirements and app code | |
| COPY requirements.txt . | |
| COPY app.py . | |
| # Install dependencies | |
| RUN pip install --upgrade pip | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Expose the default port | |
| EXPOSE 7860 | |
| # Command to run the app | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |