File size: 1,321 Bytes
af70f62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    DEBIAN_FRONTEND=noninteractive \
    PORT=7860

RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    ffmpeg \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
WORKDIR /app

COPY requirements.txt* ./
RUN pip install --no-cache-dir --upgrade pip && \
    if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi && \
    pip install --no-cache-dir PyYAML numpy opencv-python onnxruntime mediapipe ultralytics fastapi uvicorn jinja2 python-multipart imageio-ffmpeg

COPY --chown=user:user . /app

RUN mkdir -p /app/data /app/data/enrollment /app/data/unknown_faces /app/clips && \
    chown -R user:user /app

USER user
ENV HOME=/home/user \
    PATH="/home/user/.local/bin:${PATH}"

EXPOSE 7860

CMD ["python", "-c", "import os, yaml, uvicorn; cfg=yaml.safe_load(open('config.yaml', encoding='utf-8')) or {}; cfg.setdefault('system',{})['backend']='mock'; yaml.safe_dump(cfg, open('config.yaml','w',encoding='utf-8'), sort_keys=False); _run=uvicorn.run; uvicorn.run=lambda app, **kw: _run(app, **{**kw, 'host':'0.0.0.0', 'port':int(os.environ.get('PORT', 7860))}); import main; main.main()"]