Spaces:
Sleeping
Sleeping
File size: 1,278 Bytes
fbd5b5a aec6aee a6320b1 aec6aee fbd5b5a aec6aee fbd5b5a aec6aee fbd5b5a aec6aee fbd5b5a aec6aee fbd5b5a aec6aee fbd5b5a | 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 | # ββ Stage 1: Build React frontend βββββββββββββββββββββββββββββββββββββββββββ
FROM node:20-slim AS frontend-builder
WORKDIR /app
COPY package.json ./
RUN npm install --silent
COPY public/ ./public/
COPY src/ ./src/
RUN npm run build
# ββ Stage 2: Python backend ββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
git wget curl libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps first
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download all models at BUILD time so runtime starts instantly
COPY download_models.py .
RUN python download_models.py
# Copy app files
COPY server.py .
COPY --from=frontend-builder /app/build ./build
# Fix permissions for HF non-root user 1000
RUN mkdir -p /app/.cache/huggingface /app/models \
&& useradd -m -u 1000 hfuser \
&& chown -R hfuser:hfuser /app
USER 1000
ENV HF_HOME=/app/.cache/huggingface
EXPOSE 7860
CMD ["python", "server.py"]
|