MOCKMATE / Dockerfile
sriyanshcodes-dev
Initial clean commit for Hugging Face Spaces
fd13a7c
Raw History Blame Contribute Delete
1.83 kB
# Multi-stage Dockerfile for Hugging Face Spaces Deployment (SDK: Docker, Port: 7860)
# --- Stage 1: Build React Frontend ---
FROM node:18-slim AS frontend-builder
WORKDIR /app/frontend
COPY mockmate/frontend/package*.json ./
RUN npm ci || npm install
COPY mockmate/frontend/ ./
RUN npm run build
# --- Stage 2: Python Backend & Runtime ---
FROM python:3.10-slim
# Install system dependencies required by OpenCV, MediaPipe, FFmpeg, etc.
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
wget \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Hugging Face Spaces requires running as non-root user with UID 1000
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1
WORKDIR /app
# Copy and install Python requirements
COPY --chown=user:user mockmate/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download Kokoro TTS models into models directory
RUN mkdir -p /app/models && \
wget -q https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx -O /app/models/kokoro-v1.0.onnx && \
wget -q https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin -O /app/models/voices-v1.0.bin
# Copy backend and full app source code
COPY --chown=user:user mockmate/ /app/
# Copy built static frontend from Stage 1 into /app/frontend/build
COPY --chown=user:user --from=frontend-builder /app/frontend/build /app/frontend/build
# Hugging Face Spaces listens on port 7860
EXPOSE 7860
# Start FastAPI application using Uvicorn on port 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]