| # Use official PyTorch image | |
| FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime | |
| # Disable pip cache | |
| ENV PIP_NO_CACHE_DIR=1 | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first | |
| COPY requirements.txt . | |
| # Install dependencies | |
| RUN pip install --upgrade pip | |
| RUN pip install -r requirements.txt | |
| # --- CACHE BUSTING LAYER --- | |
| # Change the number below (e.g., to 2, 3) whenever you change code | |
| # and the server doesn't update. | |
| ENV BUILD_VERSION=2 | |
| # Copy application code | |
| COPY . . | |
| # Expose port | |
| EXPOSE 7860 | |
| # Run FastAPI | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |