2022-02-18 16:43:30 +03:00
|
|
|
FROM blakeblackshear/frigate-nginx:1.0.2 as nginx
|
|
|
|
|
|
|
|
|
|
FROM debian:11 as wheels
|
2022-02-22 06:11:10 +03:00
|
|
|
ARG TARGETARCH
|
2022-02-18 16:43:30 +03:00
|
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
|
|
# 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 \
|
2022-07-04 17:06:26 +03:00
|
|
|
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E \
|
|
|
|
|
&& echo "deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi" | tee /etc/apt/sources.list.d/raspi.list \
|
2022-02-18 16:43:30 +03:00
|
|
|
&& apt-get -qq update \
|
|
|
|
|
&& apt-get -qq install -y \
|
|
|
|
|
python3 \
|
|
|
|
|
python3-dev \
|
|
|
|
|
wget \
|
|
|
|
|
# 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
|
|
|
|
|
gcc gfortran libopenblas-dev liblapack-dev
|
|
|
|
|
|
|
|
|
|
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
|
|
|
|
&& python3 get-pip.py "pip"
|
|
|
|
|
|
2022-02-22 06:11:10 +03:00
|
|
|
RUN if [ "${TARGETARCH}" = "arm" ]; \
|
|
|
|
|
then echo "[global]" > /etc/pip.conf \
|
|
|
|
|
&& echo "extra-index-url=https://www.piwheels.org/simple" >> /etc/pip.conf; \
|
|
|
|
|
fi
|
|
|
|
|
|
2022-04-12 15:21:21 +03:00
|
|
|
COPY requirements.txt /requirements.txt
|
|
|
|
|
RUN pip3 install -r requirements.txt
|
2022-02-18 16:43:30 +03:00
|
|
|
|
2022-04-12 15:21:21 +03:00
|
|
|
COPY requirements-wheels.txt /requirements-wheels.txt
|
2022-04-12 16:30:55 +03:00
|
|
|
RUN pip3 wheel --wheel-dir=/wheels -r requirements-wheels.txt
|
2022-02-18 16:43:30 +03:00
|
|
|
|
2022-07-20 04:18:32 +03:00
|
|
|
# Frigate without web
|
|
|
|
|
FROM debian:11-slim AS frigate-without-web
|
2022-02-18 16:43:30 +03:00
|
|
|
ARG TARGETARCH
|
|
|
|
|
|
2022-04-24 21:52:12 +03:00
|
|
|
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
|
|
|
|
|
ARG DEBIAN_FRONTEND="noninteractive"
|
|
|
|
|
# http://stackoverflow.com/questions/48162574/ddg#49462622
|
|
|
|
|
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
|
|
|
|
|
# https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support)
|
|
|
|
|
ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
|
|
|
|
|
|
2022-02-18 16:43:30 +03:00
|
|
|
ENV FLASK_ENV=development
|
|
|
|
|
|
|
|
|
|
COPY --from=wheels /wheels /wheels
|
|
|
|
|
|
|
|
|
|
# Install ffmpeg
|
|
|
|
|
RUN apt-get -qq update \
|
|
|
|
|
&& apt-get -qq install --no-install-recommends -y \
|
|
|
|
|
apt-transport-https \
|
|
|
|
|
gnupg \
|
|
|
|
|
wget \
|
2022-11-13 21:48:14 +03:00
|
|
|
procps \
|
2022-02-18 16:43:30 +03:00
|
|
|
unzip tzdata libxml2 xz-utils \
|
|
|
|
|
python3-pip \
|
|
|
|
|
# add raspberry pi repo
|
2022-07-04 17:06:26 +03:00
|
|
|
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E \
|
|
|
|
|
&& echo "deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi" | tee /etc/apt/sources.list.d/raspi.list \
|
2022-02-18 16:43:30 +03:00
|
|
|
# add coral repo
|
2022-04-24 21:52:12 +03:00
|
|
|
&& apt-key adv --fetch-keys https://packages.cloud.google.com/apt/doc/apt-key.gpg \
|
2022-02-18 16:43:30 +03:00
|
|
|
&& echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list \
|
|
|
|
|
&& echo "libedgetpu1-max libedgetpu/accepted-eula select true" | debconf-set-selections \
|
2022-06-09 15:15:46 +03:00
|
|
|
# enable non-free repo
|
|
|
|
|
&& sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list \
|
2022-02-18 16:43:30 +03:00
|
|
|
&& apt-get -qq update \
|
2022-04-24 21:52:12 +03:00
|
|
|
&& apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
2022-02-18 16:43:30 +03:00
|
|
|
# coral drivers
|
|
|
|
|
libedgetpu1-max python3-tflite-runtime python3-pycoral \
|
|
|
|
|
&& pip3 install -U /wheels/*.whl \
|
2022-08-22 20:51:15 +03:00
|
|
|
# btbn-ffmpeg -> amd64 / arm64
|
|
|
|
|
&& if [ "${TARGETARCH}" = "amd64" ] || [ "${TARGETARCH}" = "arm64" ]; then \
|
|
|
|
|
mkdir -p /usr/lib/btbn-ffmpeg \
|
|
|
|
|
&& wget -O btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux$( [ "$TARGETARCH" = "amd64" ] && echo "64" || echo "arm64" )-gpl-5.1.tar.xz" \
|
|
|
|
|
&& tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 \
|
|
|
|
|
&& rm btbn-ffmpeg.tar.xz; \
|
|
|
|
|
fi \
|
|
|
|
|
# ffmpeg -> arm32
|
|
|
|
|
&& if [ "${TARGETARCH}" = "arm" ]; then \
|
|
|
|
|
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg; \
|
|
|
|
|
fi \
|
2022-05-14 14:36:38 +03:00
|
|
|
# arch specific packages
|
2022-04-24 21:52:12 +03:00
|
|
|
&& if [ "${TARGETARCH}" = "amd64" ]; then \
|
2022-05-14 14:36:38 +03:00
|
|
|
apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
2022-08-22 20:51:15 +03:00
|
|
|
mesa-va-drivers libva-drm2 intel-media-va-driver-non-free i965-va-driver libmfx1; \
|
2022-04-24 21:52:12 +03:00
|
|
|
fi \
|
2022-07-20 16:03:43 +03:00
|
|
|
&& if [ "${TARGETARCH}" = "arm64" ]; then \
|
|
|
|
|
apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
|
|
|
|
libva-drm2 mesa-va-drivers; \
|
2022-04-24 21:52:12 +03:00
|
|
|
fi \
|
2022-07-04 17:06:26 +03:00
|
|
|
# not sure why 32bit arm requires all these
|
|
|
|
|
&& if [ "${TARGETARCH}" = "arm" ]; then \
|
|
|
|
|
apt-get -qq install --no-install-recommends --no-install-suggests -y \
|
|
|
|
|
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; \
|
|
|
|
|
fi \
|
2022-04-24 21:52:12 +03:00
|
|
|
&& rm -rf /wheels \
|
|
|
|
|
&& apt-get remove gnupg apt-transport-https -y \
|
|
|
|
|
&& apt-get clean autoclean -y \
|
|
|
|
|
&& apt-get autoremove -y \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2022-02-22 15:56:53 +03:00
|
|
|
|
2022-08-22 20:51:15 +03:00
|
|
|
ENV PATH=$PATH:/usr/lib/btbn-ffmpeg/bin
|
2022-04-26 15:18:13 +03:00
|
|
|
|
2022-11-02 14:36:09 +03:00
|
|
|
# install go2rtc
|
2022-11-09 04:48:36 +03:00
|
|
|
RUN wget -O go2rtc "https://github.com/AlexxIT/go2rtc/releases/download/v0.1-rc.2/go2rtc_linux_${TARGETARCH}" \
|
2022-11-02 14:36:09 +03:00
|
|
|
&& chmod +x go2rtc \
|
|
|
|
|
&& mkdir -p /usr/local/go2rtc/sbin/ \
|
|
|
|
|
&& mv go2rtc /usr/local/go2rtc/sbin/go2rtc
|
2022-04-26 15:18:13 +03:00
|
|
|
|
2022-02-18 16:43:30 +03:00
|
|
|
COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
|
|
|
|
|
|
|
|
|
|
# get model and labels
|
|
|
|
|
COPY labelmap.txt /labelmap.txt
|
|
|
|
|
RUN wget -q https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite -O /edgetpu_model.tflite
|
|
|
|
|
RUN wget -q https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite -O /cpu_model.tflite
|
|
|
|
|
|
|
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
|
ADD frigate frigate/
|
|
|
|
|
ADD migrations migrations/
|
|
|
|
|
|
|
|
|
|
COPY docker/rootfs/ /
|
|
|
|
|
|
|
|
|
|
# s6-overlay
|
|
|
|
|
RUN S6_ARCH="${TARGETARCH}" \
|
|
|
|
|
&& if [ "${TARGETARCH}" = "amd64" ]; then S6_ARCH="amd64"; fi \
|
2022-02-22 06:11:10 +03:00
|
|
|
&& if [ "${TARGETARCH}" = "arm" ]; then S6_ARCH="armhf"; fi \
|
2022-02-18 16:43:30 +03:00
|
|
|
&& if [ "${TARGETARCH}" = "arm64" ]; then S6_ARCH="aarch64"; fi \
|
|
|
|
|
&& wget -O /tmp/s6-overlay-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-${S6_ARCH}-installer" \
|
|
|
|
|
&& chmod +x /tmp/s6-overlay-installer && /tmp/s6-overlay-installer /
|
|
|
|
|
|
|
|
|
|
EXPOSE 5000
|
|
|
|
|
EXPOSE 1935
|
2022-11-02 14:36:09 +03:00
|
|
|
EXPOSE 8554
|
|
|
|
|
EXPOSE 8555
|
2022-02-18 16:43:30 +03:00
|
|
|
|
|
|
|
|
ENTRYPOINT ["/init"]
|
|
|
|
|
|
|
|
|
|
CMD ["python3", "-u", "-m", "frigate"]
|
2022-07-20 04:18:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Frigate with Node.js and NPM
|
|
|
|
|
FROM frigate-without-web AS frigate-with-node
|
|
|
|
|
|
|
|
|
|
# Install Node 16
|
|
|
|
|
RUN apt-get update -y \
|
|
|
|
|
&& apt-get install -y curl \
|
|
|
|
|
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
|
|
|
|
|
&& apt-get install -y nodejs
|
|
|
|
|
|
|
|
|
|
RUN npm install -g npm@latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Build of the Frigate web
|
|
|
|
|
FROM frigate-with-node AS web-build
|
|
|
|
|
|
|
|
|
|
WORKDIR /work
|
|
|
|
|
COPY web/package.json web/package-lock.json ./
|
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
|
|
COPY web/ ./
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Frigate Container
|
|
|
|
|
FROM frigate-without-web
|
|
|
|
|
|
|
|
|
|
COPY --from=build-web /work/dist web/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Devcontainer
|
|
|
|
|
FROM frigate-with-node AS dev
|
|
|
|
|
|
|
|
|
|
ARG USERNAME=vscode
|
|
|
|
|
ARG USER_UID=1000
|
|
|
|
|
ARG USER_GID=$USER_UID
|
|
|
|
|
|
|
|
|
|
# Create the user
|
|
|
|
|
RUN groupadd --gid $USER_GID $USERNAME \
|
|
|
|
|
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
|
|
|
|
|
#
|
|
|
|
|
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
|
|
|
|
|
&& apt-get update \
|
|
|
|
|
&& apt-get install -y sudo \
|
|
|
|
|
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
|
|
|
|
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
|
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
|
&& apt-get install -y git curl vim htop
|
|
|
|
|
|
|
|
|
|
COPY requirements-dev.txt /opt/frigate/requirements-dev.txt
|
|
|
|
|
RUN pip3 install -r requirements-dev.txt
|