Spaces:
Paused
Paused
File size: 1,063 Bytes
2994724 55f3c9c 6c245bf 2994724 55f3c9c 9f1e6a2 2994724 6c245bf 2994724 55f3c9c 2994724 6c245bf 2994724 ecedeb4 2994724 2d54740 2994724 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# β
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"]
|