File size: 1,831 Bytes
fd13a7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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"]