Spaces:
Sleeping
Sleeping
File size: 1,286 Bytes
44603cf | 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 36 37 38 39 40 41 42 43 44 45 | # ---------- Base Image ----------
FROM python:3.12-slim
# ---------- Environment ----------
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/tmp/hf_cache \
TRANSFORMERS_CACHE=/tmp/hf_cache \
SENTENCE_TRANSFORMERS_HOME=/tmp/hf_cache
# ---------- Working Directory ----------
WORKDIR /app
# ---------- System Dependencies ----------
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
libgl1 \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 && \
rm -rf /var/lib/apt/lists/*
# ---------- Copy Backend Files ----------
# On HuggingFace Spaces, your backend folder sits at repo root
COPY backend/ /app/backend/
COPY backend/requirements.txt /app/requirements.txt
# ---------- Python Dependencies ----------
RUN pip install --upgrade pip setuptools wheel && \
pip install --no-cache-dir \
torch==2.4.1+cpu \
torchvision==0.19.1+cpu \
--index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir -r /app/requirements.txt
# ---------- Expose Port ----------
EXPOSE 7860
# ---------- Run FastAPI ----------
WORKDIR /app/backend
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|