File size: 1,427 Bytes
7b53d75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

RUN useradd -m -u 1000 user
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
    libglib2.0-0 libsm6 libxrender1 libxext6 libxcb1 libgl1 libgomp1 \
    ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev \
    libavdevice-dev libopus-dev libvpx-dev libsrtp2-dev \
    build-essential nodejs npm git \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu

# Python deps (separate layer for caching)
COPY requirements.txt ./
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu \
    && pip install --no-cache-dir -r requirements.txt

# Copy source (respects .dockerignore)
COPY . .

# Build frontend
RUN npm install && npm run build && mkdir -p /app/static && cp -R dist/* /app/static/ \
    && rm -rf node_modules dist

# Download models at build time
ENV FOCUSGUARD_CACHE_DIR=/app/.cache/focusguard
RUN python -c "from models.face_mesh import _ensure_model; _ensure_model()"
RUN python download_l2cs_weights.py || echo "[WARN] L2CS weights not downloaded — will run without gaze model"

RUN mkdir -p /app/data && chown -R user:user /app

USER user
EXPOSE 7860

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]