Spaces:
Running
Running
File size: 2,015 Bytes
c566c01 88cfebc c566c01 88cfebc c566c01 c20c0b4 88cfebc 0bd81e7 de5487e 6fb0d9b 88cfebc 6fb0d9b 88cfebc 0bd81e7 88cfebc 0bd81e7 c566c01 88cfebc c566c01 88cfebc c566c01 88cfebc c566c01 6fb0d9b | 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # ============================================================
# InnerVoice — Hugging Face Spaces Docker Deployment
# ============================================================
# ---------- Stage 1: Build the Next.js frontend ----------
FROM node:20-slim AS frontend_builder
WORKDIR /build/frontend
COPY frontend/package*.json ./
RUN npm ci --no-audit --no-fund
COPY frontend/ ./
RUN npm run build
# ---------- Stage 2: Final runtime ----------
FROM python:3.10-slim
# Copy Node.js binaries from official node image (no apt needed)
COPY --from=node:20-slim /usr/local/bin /usr/local/bin
COPY --from=node:20-slim /usr/local/lib/node_modules /usr/local/lib/node_modules
# Install only system-level deps
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
build-essential \
git \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# HF Spaces user
RUN useradd -m -u 1000 user
ENV HOME=/home/user
ENV PATH=$HOME/.local/bin:$PATH
WORKDIR $HOME/app
RUN chown -R user:user $HOME
USER user
# Python deps (CPU-only PyTorch)
COPY --chown=user:user backend/requirements.txt ./backend/
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir \
-r backend/requirements.txt \
--extra-index-url https://download.pytorch.org/whl/cpu
# Copy pre-built frontend from Stage 1
COPY --from=frontend_builder --chown=user:user /build/frontend/.next ./frontend/.next
COPY --from=frontend_builder --chown=user:user /build/frontend/node_modules ./frontend/node_modules
COPY --from=frontend_builder --chown=user:user /build/frontend/package.json ./frontend/package.json
COPY --from=frontend_builder --chown=user:user /build/frontend/public ./frontend/public
COPY --from=frontend_builder --chown=user:user /build/frontend/next.config.mjs ./frontend/next.config.mjs
# Copy backend
COPY --chown=user:user backend/ ./backend/
# Entrypoint
COPY --chown=user:user start.sh ./
RUN chmod +x start.sh
EXPOSE 7860
CMD ["./start.sh"]
|