Subhakanta156's picture
removed cache buildup
4699653 verified
raw
history blame contribute delete
963 Bytes
# 1️⃣ Base image
FROM python:3.11-slim
# Prevent Python from writing pyc files & buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# 2️⃣ Set working directory
WORKDIR /app
# 3️⃣ Install OS dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 4️⃣ Set Hugging Face cache to /tmp (auto-cleaned by system)
ENV HF_HOME=/tmp/.huggingface
RUN mkdir -p /tmp/.huggingface
# 5️⃣ Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 6️⃣ REMOVED: Pre-download was causing cache buildup
# Model will download at runtime to /tmp instead
# This prevents Docker layer accumulation
# 7️⃣ Copy the entire project
COPY . .
# 8️⃣ Expose HF Spaces default port
EXPOSE 7860
# 9️⃣ Run the app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]