-
Notifications
You must be signed in to change notification settings - Fork 32
/
Dockerfile.base
84 lines (71 loc) · 2.92 KB
/
Dockerfile.base
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM ubuntu:20.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
ENV TF_CPP_MIN_LOG_LEVEL=2
# Install basic packages
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
wget \
gnupg2 \
python3-pip \
&& python3 -m pip install --upgrade \
pip \
setuptools \
wheel \
&& rm -rf /var/lib/apt/lists/*
#
# Use the previous stage as a new temporary stage for building libraries
#
FROM base AS builder
LABEL watsor.builder="watsor.base.builder"
# Build Wheel archives for the requirements and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip wheel --wheel-dir=/tmp/install \
PyYaml \
cerberus \
numpy==1.23.* \
scipy \
opencv-python-headless \
shapely \
werkzeug \
paho-mqtt \
tensorflow \
https://github.com/google-coral/pycoral/releases/download/v2.0.0/tflite_runtime-2.5.0.post1-cp38-cp38-linux_x86_64.whl
#
# Copy libraries to the final image
#
FROM base AS result
COPY --from=builder /tmp/install /tmp/install
# Install Wheel archives built at previous stage
RUN python3 -m pip install --upgrade /tmp/install/* \
&& rm -r /tmp/install
# Install FFmpeg and VAAPI drivers for Intel hardware acceleration
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libva-drm2 libva2 i965-va-driver vainfo \
&& rm -rf /var/lib/apt/lists/*
# Install the Edge TPU runtime
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list && \
wget -q -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && apt-get install -y --no-install-recommends \
libedgetpu1-std \
python3-pycoral \
&& rm -rf /var/lib/apt/lists/*
# Dedicated user
RUN mkdir /etc/watsor /usr/share/watsor /var/log/watsor && \
addgroup -gid 1001 watsor && \
adduser -uid 1001 -gid 1001 -gecos watsor -home /usr/share/watsor --no-create-home --disabled-password watsor && \
usermod -a --groups video,plugdev watsor && \
chown -R watsor /etc/watsor /usr/share/watsor /var/log/watsor
# Download object detection models
RUN mkdir model && \
wget -q https://github.com/google-coral/test_data/raw/master/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite -O model/edgetpu.tflite --trust-server-names && \
wget -q http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz -O model/cpu.tar.gz && \
tar -xf model/cpu.tar.gz -C model ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb --strip-components 1 && \
mv model/frozen_inference_graph.pb model/cpu.pb && \
rm model/cpu.tar.gz && \
mv model /usr/share/watsor/model && \
chown -R watsor:watsor /usr/share/watsor/model
EXPOSE 8080