stylsteer-vlm / Dockerfile
abka03's picture
Fix Node.js 18 + CUDA 12.1 torch index
ad4c439 verified
# ================================================================
# StyleSteer-VLM — Hugging Face Spaces Dockerfile
# Docker SDK: GPU (CUDA 12.1)
# ================================================================
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
# System packages + Node.js 18 (Vite 6 requires Node >= 18)
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.10 python3-pip python3.10-venv \
git curl ca-certificates gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Set python3.10 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \
&& python -m pip install --upgrade pip
# Create non-root user (HF Spaces requirement)
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
# --- Python dependencies (torch first — CUDA 12.1 wheel) ---
COPY requirements-deploy.txt .
RUN pip install --no-cache-dir \
torch torchvision \
--extra-index-url https://download.pytorch.org/whl/cu121 \
&& pip install --no-cache-dir -r requirements-deploy.txt
# --- Build frontend ---
COPY demo/frontend/package.json demo/frontend/package-lock.json* demo/frontend/
RUN cd demo/frontend && npm ci --prefer-offline 2>/dev/null || (cd demo/frontend && npm install)
COPY demo/frontend/ demo/frontend/
RUN cd demo/frontend && npm run build
# --- Copy backend + project source ---
COPY src/ src/
COPY configs/ configs/
COPY demo/backend/ demo/backend/
COPY demo/__init__.py demo/__init__.py
COPY start.sh start.sh
# --- Serve frontend static files from FastAPI ---
COPY serve_static.py serve_static.py
# Move built frontend dist into a known location
RUN mv demo/frontend/dist static
# Create data dirs (sample images will be fetched at runtime if needed)
RUN mkdir -p data/coco_val2017/images
# Permissions for HF Spaces
RUN chown -R user:user /home/user/app
USER user
# --- Environment variables ---
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/home/user/app
ENV HF_HOME=/home/user/.cache/huggingface
ENV PORT=7860
EXPOSE 7860
CMD ["bash", "start.sh"]