harmesh95's picture
Rename Dockerfile.backend to Dockerfile
4653b3a verified
# ---------- 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"]