new_LDM_hosting / Dockerfile
Manjeet9812's picture
Update Dockerfile
449f29f verified
# ===== Dockerfile =====
FROM python:3.10-slim
# System deps (git needed for CLIP-from-git)
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
# Writable HOME so ~/.cache -> /data/.cache
# Hugging Face caches -> /data (persistent on Spaces)
ENV HOME=/data \
XDG_CACHE_HOME=/data/.cache \
TRANSFORMERS_CACHE=/data/transformers \
HF_HOME=/data/.cache/huggingface \
HUGGINGFACE_HUB_CACHE=/data/.cache/huggingface/hub \
TF_ENABLE_ONEDNN_OPTS=0
RUN mkdir -p $HOME $XDG_CACHE_HOME $TRANSFORMERS_CACHE $HUGGINGFACE_HUB_CACHE \
&& chmod -R 777 /data
WORKDIR /app
# Install Python deps first
COPY requirements.txt /app/requirements.txt
RUN python -m pip install --upgrade pip && \
pip install --no-cache-dir -r /app/requirements.txt
# Copy app code
COPY server.py /app/server.py
# (keep index.html/README if you want; they’re not required for API)
# Start FastAPI (Spaces injects $PORT)
CMD ["sh", "-lc", "uvicorn server:app --host 0.0.0.0 --port ${PORT:-7860}"]