Spaces:
Running
Running
# β Base image | |
FROM python:3.10-slim | |
# β Install system dependencies | |
RUN apt-get update && apt-get install -y gcc g++ make | |
# β Create working directory with write permissions (Hugging Face specific) | |
WORKDIR /app | |
RUN mkdir -p /app/.cache /tmp/.triton /tmp/torchinductor_cache && chmod -R 777 /app/.cache /tmp/.triton /tmp/torchinductor_cache | |
# β Environment variables for Hugging Face caching | |
ENV HF_HOME=/app/.cache \ | |
HF_DATASETS_CACHE=/app/.cache \ | |
HF_HUB_CACHE=/app/.cache \ | |
TRITON_CACHE_DIR=/tmp/.triton \ | |
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache | |
# β Copy requirements and install | |
COPY requirements.txt ./ | |
RUN pip install --no-cache-dir -r requirements.txt | |
# β Copy all project files | |
COPY . . | |
# β Expose FastAPI port | |
EXPOSE 7860 | |
# β Health check dummy server (important for Hugging Face Spaces) | |
# This will run as a background thread inside Python, not as a separate Docker CMD | |
# so we only run uvicorn in CMD below. | |
# β Final startup command | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |