Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (37 loc) · 2.05 KB
/
Copy pathDockerfile
File metadata and controls
46 lines (37 loc) · 2.05 KB
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
# Standalone container — for Home Assistant Container/Core users, who cannot install
# apps, and for anyone who would rather not run this on the host.
#
# docker compose up -d (see docker-compose.yml)
#
# config.yaml and the gallery live in mounted volumes, so both survive image updates.
FROM python:3.12-slim
# InsightFace caches its model pack under $HOME/.insightface — pointing HOME into the
# data volume keeps the ~300 MB out of the image and avoids a re-download after updates.
ENV PYTHONUNBUFFERED=1 \
HOME=/opt/faceid/data/model-cache
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential curl ca-certificates ffmpeg \
libglib2.0-0 libgl1 libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/faceid
RUN mkdir -p /opt/faceid/models \
&& curl -fL --retry 3 -o /opt/faceid/models/dinov2-small.onnx \
https://huggingface.co/onnx-community/dinov2-small-ONNX/resolve/main/onnx/model.onnx \
&& echo "6266c3cd72db6953cecdcbfeab9422a9f783d96f1a4e296ba70ffbac43b54a18 /opt/faceid/models/dinov2-small.onnx" | sha256sum -c -
RUN curl -fL --retry 3 -o /opt/faceid/models/liveness.onnx \
https://raw.githubusercontent.com/facenox/face-antispoof-onnx/2d4b33a3c0ba6e27772ac3a9b48ec495bf5c1dad/models/best_model_quantized.onnx \
&& echo "fde20585635cae62ed1d41796f76b6f8bc4b92cd91ec1cf0f1bc6485d2d587a9 /opt/faceid/models/liveness.onnx" | sha256sum -c -
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get purge -y build-essential && apt-get autoremove -y
COPY app app
COPY static static
COPY scripts scripts
COPY docs/example-config.yaml docs/example-config.yaml
# Gallery, settings and the downloaded model pack — mount this.
VOLUME ["/opt/faceid/data"]
EXPOSE 8600
HEALTHCHECK --interval=30s --timeout=5s --start-period=180s \
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8600/api/health',timeout=4).status==200 else 1)"
CMD ["python", "-m", "app.main"]