File size: 2,611 Bytes
cb1bd97
a265585
cb1bd97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a265585
468f785
 
a265585
 
cb1bd97
a265585
cb1bd97
 
a265585
 
cb1bd97
a265585
cb1bd97
 
a265585
 
cb1bd97
a265585
cb1bd97
a85acb5
 
 
 
 
cb1bd97
a265585
cb1bd97
 
 
0a64934
f37f11d
0a64934
cb1bd97
 
 
 
 
 
 
 
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
# Ethos Studio β€” HuggingFace Spaces Docker deployment
# Architecture: Python API (8000) + Node proxy (3000) + Next.js (3030)
#               nginx on port 7860 routes traffic between layers

FROM python:3.11-slim

# ─── System dependencies ──────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
    ffmpeg curl nginx supervisor \
    && rm -rf /var/lib/apt/lists/*

# Node.js 22
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# ─── API layer: Python dependencies ──────────────────────────────────────────
# CACHE_BUST: force pip layer rebuild when bumping onnxruntime version
ARG CACHE_BUST=20260302
COPY api/requirements.txt api/requirements.txt
RUN pip install --no-cache-dir -r api/requirements.txt

COPY api/ api/

# ─── Proxy server: Node dependencies ─────────────────────────────────────────
COPY proxy/package*.json proxy/
RUN cd proxy && npm ci --omit=dev

COPY proxy/ proxy/

# ─── Frontend: Next.js build ──────────────────────────────────────────────────
COPY web/package*.json web/
RUN cd web && npm ci

COPY web/ web/

# Download browser-side FER model (ONNX) β€” not in HF Space git (Xet restriction)
RUN curl -fsSL \
    "https://raw.githubusercontent.com/aytoast/ser/master/web/public/emotion_model_web.onnx" \
    -o web/public/emotion_model_web.onnx

# Build with empty API base β†’ browser uses relative paths β†’ nginx routes /api/*
RUN cd web && NEXT_PUBLIC_API_URL="" npm run build \
    && cp -r public .next/standalone/public \
    && cp -r .next/static .next/standalone/.next/static

# ─── FER model (MobileViT-XXS ONNX, 8-class facial emotion) ─────────────────
COPY models/ models/

# ─── Process manager + reverse proxy config ───────────────────────────────────
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisor/conf.d/app.conf

# HuggingFace Spaces public port
EXPOSE 7860

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/app.conf"]