2023-10-07 16:21:03 +02:00
|
|
|
# syntax=docker/dockerfile:1.6
|
2022-11-16 13:27:37 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2023-07-26 12:50:41 +02:00
|
|
|
ARG BASE_IMAGE=debian:11
|
|
|
|
ARG SLIM_BASE=debian:11-slim
|
|
|
|
|
|
|
|
FROM ${BASE_IMAGE} AS base
|
2022-11-22 02:31:39 +01:00
|
|
|
|
2023-07-29 02:27:53 +02:00
|
|
|
FROM --platform=${BUILDPLATFORM} debian:11 AS base_host
|
2022-12-03 17:19:34 +01:00
|
|
|
|
2023-07-26 12:50:41 +02:00
|
|
|
FROM ${SLIM_BASE} AS slim-base
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
FROM slim-base AS wget
|
|
|
|
ARG DEBIAN_FRONTEND
|
|
|
|
RUN apt-get update \
|
2022-12-03 17:23:19 +01:00
|
|
|
&& apt-get install -y wget xz-utils \
|
2022-11-22 02:31:39 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /rootfs
|
|
|
|
|
2022-12-18 02:39:42 +01:00
|
|
|
FROM base AS nginx
|
2022-12-18 00:53:34 +01:00
|
|
|
ARG DEBIAN_FRONTEND
|
2023-06-30 14:28:48 +02:00
|
|
|
ENV CCACHE_DIR /root/.ccache
|
|
|
|
ENV CCACHE_MAXSIZE 2G
|
2022-12-18 00:53:34 +01:00
|
|
|
|
2023-01-06 13:48:41 +01:00
|
|
|
# bind /var/cache/apt to tmpfs to speed up nginx build
|
|
|
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
|
2023-07-23 23:45:29 +02:00
|
|
|
--mount=type=bind,source=docker/main/build_nginx.sh,target=/deps/build_nginx.sh \
|
2023-06-30 14:28:48 +02:00
|
|
|
--mount=type=cache,target=/root/.ccache \
|
2023-01-06 13:48:41 +01:00
|
|
|
/deps/build_nginx.sh
|
2022-11-22 02:31:39 +01:00
|
|
|
|
2023-07-29 04:33:21 +02:00
|
|
|
FROM scratch AS go2rtc
|
2022-11-22 02:31:39 +01:00
|
|
|
ARG TARGETARCH
|
|
|
|
WORKDIR /rootfs/usr/local/go2rtc/bin
|
2024-06-19 16:46:23 +02:00
|
|
|
ADD --link --chmod=755 "https://github.com/AlexxIT/go2rtc/releases/download/v1.9.4/go2rtc_linux_${TARGETARCH}" go2rtc
|
2022-11-22 02:31:39 +01:00
|
|
|
|
2024-06-02 15:47:11 +02:00
|
|
|
FROM wget AS tempio
|
2024-06-02 14:48:28 +02:00
|
|
|
ARG TARGETARCH
|
2024-06-02 15:47:11 +02:00
|
|
|
RUN --mount=type=bind,source=docker/main/install_tempio.sh,target=/deps/install_tempio.sh \
|
|
|
|
/deps/install_tempio.sh
|
2022-12-30 17:53:17 +01:00
|
|
|
|
|
|
|
####
|
|
|
|
#
|
|
|
|
# OpenVino Support
|
|
|
|
#
|
|
|
|
# 1. Download and convert a model from Intel's Public Open Model Zoo
|
|
|
|
#
|
|
|
|
####
|
2022-12-03 17:19:34 +01:00
|
|
|
# Download and Convert OpenVino model
|
2023-07-29 02:27:53 +02:00
|
|
|
FROM base_host AS ov-converter
|
2022-12-03 17:19:34 +01:00
|
|
|
ARG DEBIAN_FRONTEND
|
|
|
|
|
|
|
|
# Install OpenVino Runtime and Dev library
|
2023-07-23 23:45:29 +02:00
|
|
|
COPY docker/main/requirements-ov.txt /requirements-ov.txt
|
2022-12-03 17:19:34 +01:00
|
|
|
RUN apt-get -qq update \
|
2024-05-09 15:22:34 +02:00
|
|
|
&& apt-get -qq install -y wget python3 python3-dev python3-distutils gcc pkg-config libhdf5-dev \
|
2022-12-03 17:19:34 +01:00
|
|
|
&& wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
|
|
|
&& python3 get-pip.py "pip" \
|
|
|
|
&& pip install -r /requirements-ov.txt
|
|
|
|
|
|
|
|
# Get OpenVino Model
|
2024-05-27 22:49:35 +02:00
|
|
|
RUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \
|
|
|
|
mkdir /models && cd /models \
|
|
|
|
&& wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \
|
|
|
|
&& tar -xvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz \
|
|
|
|
&& python3 /build_ov_model.py
|
2022-12-03 17:19:34 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
FROM wget AS models
|
|
|
|
|
|
|
|
# Get model and labels
|
|
|
|
RUN wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite
|
|
|
|
RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite
|
|
|
|
COPY labelmap.txt .
|
2022-12-03 17:19:34 +01:00
|
|
|
# Copy OpenVino model
|
2024-05-27 22:49:35 +02:00
|
|
|
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.xml openvino-model/
|
|
|
|
COPY --from=ov-converter /models/ssdlite_mobilenet_v2.bin openvino-model/
|
2023-01-06 14:03:16 +01:00
|
|
|
RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt && \
|
|
|
|
sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt
|
2023-07-01 15:18:33 +02:00
|
|
|
# Get Audio Model and labels
|
|
|
|
RUN wget -qO cpu_audio_model.tflite https://tfhub.dev/google/lite-model/yamnet/classification/tflite/1?lite-format=tflite
|
|
|
|
COPY audio-labelmap.txt .
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
FROM wget AS s6-overlay
|
2022-02-22 04:11:10 +01:00
|
|
|
ARG TARGETARCH
|
2023-07-23 23:45:29 +02:00
|
|
|
RUN --mount=type=bind,source=docker/main/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \
|
2022-11-22 02:31:39 +01:00
|
|
|
/deps/install_s6_overlay.sh
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
FROM base AS wheels
|
|
|
|
ARG DEBIAN_FRONTEND
|
2022-11-24 03:00:45 +01:00
|
|
|
ARG TARGETARCH
|
2022-02-18 14:43:30 +01:00
|
|
|
|
|
|
|
# Use a separate container to build wheels to prevent build dependencies in final image
|
|
|
|
RUN apt-get -qq update \
|
|
|
|
&& apt-get -qq install -y \
|
|
|
|
apt-transport-https \
|
|
|
|
gnupg \
|
|
|
|
wget \
|
2023-10-10 01:16:05 +02:00
|
|
|
# the key fingerprint can be obtained from https://ftp-master.debian.org/keys.html
|
|
|
|
&& wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA4285295FC7B1A81600062A9605C66F00D6C9793" | \
|
|
|
|
gpg --dearmor > /usr/share/keyrings/debian-archive-bullseye-stable.gpg \
|
|
|
|
&& echo "deb [signed-by=/usr/share/keyrings/debian-archive-bullseye-stable.gpg] http://deb.debian.org/debian bullseye main contrib non-free" | \
|
|
|
|
tee /etc/apt/sources.list.d/debian-bullseye-nonfree.list \
|
2022-02-18 14:43:30 +01:00
|
|
|
&& apt-get -qq update \
|
|
|
|
&& apt-get -qq install -y \
|
2023-07-26 12:50:41 +02:00
|
|
|
python3.9 \
|
|
|
|
python3.9-dev \
|
2022-02-18 14:43:30 +01:00
|
|
|
# opencv dependencies
|
|
|
|
build-essential cmake git pkg-config libgtk-3-dev \
|
|
|
|
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
|
|
|
|
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
|
|
|
|
gfortran openexr libatlas-base-dev libssl-dev\
|
|
|
|
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
|
|
|
|
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
|
|
|
|
# scipy dependencies
|
2023-07-16 14:42:56 +02:00
|
|
|
gcc gfortran libopenblas-dev liblapack-dev && \
|
2022-12-30 17:53:17 +01:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2023-07-26 12:50:41 +02:00
|
|
|
# Ensure python3 defaults to python3.9
|
|
|
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
|
|
|
|
|
2022-02-18 14:43:30 +01:00
|
|
|
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
|
|
|
&& python3 get-pip.py "pip"
|
|
|
|
|
2023-07-23 23:45:29 +02:00
|
|
|
COPY docker/main/requirements.txt /requirements.txt
|
2023-07-26 12:50:41 +02:00
|
|
|
RUN pip3 install -r /requirements.txt
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2023-07-23 23:45:29 +02:00
|
|
|
COPY docker/main/requirements-wheels.txt /requirements-wheels.txt
|
2023-07-26 12:50:41 +02:00
|
|
|
RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
# Collect deps in a single layer
|
|
|
|
FROM scratch AS deps-rootfs
|
|
|
|
COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
|
|
|
|
COPY --from=go2rtc /rootfs/ /
|
2024-06-02 14:48:28 +02:00
|
|
|
COPY --from=tempio /rootfs/ /
|
2022-11-22 02:31:39 +01:00
|
|
|
COPY --from=s6-overlay /rootfs/ /
|
|
|
|
COPY --from=models /rootfs/ /
|
2023-07-23 23:45:29 +02:00
|
|
|
COPY docker/main/rootfs/ /
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
|
2022-11-20 14:34:12 +01:00
|
|
|
# Frigate deps (ffmpeg, python, nginx, go2rtc, s6-overlay, etc)
|
2022-11-22 02:31:39 +01:00
|
|
|
FROM slim-base AS deps
|
2022-02-18 14:43:30 +01:00
|
|
|
ARG TARGETARCH
|
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
ARG DEBIAN_FRONTEND
|
2022-04-24 20:52:12 +02:00
|
|
|
# http://stackoverflow.com/questions/48162574/ddg#49462622
|
|
|
|
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
|
2022-11-22 02:31:39 +01:00
|
|
|
|
2022-04-24 20:52:12 +02:00
|
|
|
# https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support)
|
2022-12-31 16:13:08 +01:00
|
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
2022-04-24 20:52:12 +02:00
|
|
|
ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
|
|
|
|
|
2024-06-02 14:48:28 +02:00
|
|
|
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}"
|
2022-04-26 14:18:13 +02:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
# Install dependencies
|
2023-07-23 23:45:29 +02:00
|
|
|
RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \
|
2022-11-22 02:31:39 +01:00
|
|
|
/deps/install_deps.sh
|
2022-11-02 12:36:09 +01:00
|
|
|
|
2022-11-24 03:00:45 +01:00
|
|
|
RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
|
2023-07-26 12:50:41 +02:00
|
|
|
python3 -m pip install --upgrade pip && \
|
2022-11-24 03:00:45 +01:00
|
|
|
pip3 install -U /deps/wheels/*.whl
|
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
COPY --from=deps-rootfs / /
|
2022-02-18 14:43:30 +01:00
|
|
|
|
|
|
|
EXPOSE 5000
|
2022-11-02 12:36:09 +01:00
|
|
|
EXPOSE 8554
|
2023-01-18 14:53:53 +01:00
|
|
|
EXPOSE 8555/tcp 8555/udp
|
|
|
|
|
2022-12-09 03:15:00 +01:00
|
|
|
# Configure logging to prepend timestamps, log to stdout, keep 0 archives and rotate on 10MB
|
|
|
|
ENV S6_LOGGING_SCRIPT="T 1 n0 s10000000 T"
|
2024-02-10 13:41:46 +01:00
|
|
|
# Do not fail on long-running download scripts
|
|
|
|
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0
|
2022-12-07 14:47:40 +01:00
|
|
|
|
2022-02-18 14:43:30 +01:00
|
|
|
ENTRYPOINT ["/init"]
|
2022-12-07 14:47:40 +01:00
|
|
|
CMD []
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2023-10-07 16:21:03 +02:00
|
|
|
HEALTHCHECK --start-period=120s --start-interval=5s --interval=15s --timeout=5s --retries=3 \
|
|
|
|
CMD curl --fail --silent --show-error http://127.0.0.1:5000/api/version || exit 1
|
|
|
|
|
2022-11-24 03:00:45 +01:00
|
|
|
# Frigate deps with Node.js and NPM for devcontainer
|
|
|
|
FROM deps AS devcontainer
|
2022-11-20 14:34:12 +01:00
|
|
|
|
2022-12-07 14:47:40 +01:00
|
|
|
# Do not start the actual Frigate service on devcontainer as it will be started by VSCode
|
|
|
|
# But start a fake service for simulating the logs
|
2023-07-23 23:45:29 +02:00
|
|
|
COPY docker/main/fake_frigate_run /etc/s6-overlay/s6-rc.d/frigate/run
|
2022-12-07 14:47:40 +01:00
|
|
|
|
2023-02-19 20:11:12 +01:00
|
|
|
# Create symbolic link to the frigate source code, as go2rtc's create_config.sh uses it
|
|
|
|
RUN mkdir -p /opt/frigate \
|
|
|
|
&& ln -svf /workspace/frigate/frigate /opt/frigate/frigate
|
|
|
|
|
2023-11-18 15:04:43 +01:00
|
|
|
# Install Node 20
|
|
|
|
RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \
|
|
|
|
chmod 500 nsolid_setup_deb.sh && \
|
|
|
|
./nsolid_setup_deb.sh 20 && \
|
|
|
|
apt-get install nodejs -y \
|
2022-11-22 02:31:39 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
2023-11-18 15:04:43 +01:00
|
|
|
&& npm install -g npm@10
|
2022-11-20 14:34:12 +01:00
|
|
|
|
|
|
|
WORKDIR /workspace/frigate
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install make -y \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2023-07-23 23:45:29 +02:00
|
|
|
RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \
|
2022-11-20 14:34:12 +01:00
|
|
|
pip3 install -r requirements-dev.txt
|
|
|
|
|
2024-05-18 18:36:13 +02:00
|
|
|
HEALTHCHECK NONE
|
|
|
|
|
2022-11-20 14:34:12 +01:00
|
|
|
CMD ["sleep", "infinity"]
|
|
|
|
|
|
|
|
|
|
|
|
# Frigate web build
|
2023-06-05 23:13:54 +02:00
|
|
|
# This should be architecture agnostic, so speed up the build on multiarch by not using QEMU.
|
2023-12-16 17:20:59 +01:00
|
|
|
FROM --platform=$BUILDPLATFORM node:20 AS web-build
|
2022-11-20 14:34:12 +01:00
|
|
|
|
|
|
|
WORKDIR /work
|
|
|
|
COPY web/package.json web/package-lock.json ./
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
COPY web/ ./
|
2022-12-18 00:55:41 +01:00
|
|
|
RUN npm run build \
|
|
|
|
&& mv dist/BASE_PATH/monacoeditorwork/* dist/assets/ \
|
|
|
|
&& rm -rf dist/BASE_PATH
|
2022-11-20 14:34:12 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
# Collect final files in a single layer
|
|
|
|
FROM scratch AS rootfs
|
2022-11-20 14:34:12 +01:00
|
|
|
|
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
COPY frigate frigate/
|
|
|
|
COPY migrations migrations/
|
2022-11-24 03:00:45 +01:00
|
|
|
COPY --from=web-build /work/dist/ web/
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
# Frigate final container
|
2022-12-30 17:53:17 +01:00
|
|
|
FROM deps AS frigate
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
COPY --from=rootfs / /
|