integration_test2 / Dockerfile
Abdelrahman Almatrooshi
FocusGuard with L2CS-Net gaze estimation
7b53d75
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"]