mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
docker refactoring
This commit is contained in:
parent
e2c5bfec8b
commit
fbbcad49e8
@ -23,32 +23,7 @@ RUN apt-get -qq update \
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-aarch64-installer /tmp/
|
||||
RUN chmod +x /tmp/s6-overlay-aarch64-installer && /tmp/s6-overlay-aarch64-installer /
|
||||
|
||||
# setup gstreamer
|
||||
RUN \
|
||||
apt-get update && apt-get install -y software-properties-common && \
|
||||
add-apt-repository universe && \
|
||||
add-apt-repository multiverse && \
|
||||
apt-get update
|
||||
|
||||
RUN \
|
||||
apt-get install -y gstreamer1.0-tools gstreamer1.0-alsa \
|
||||
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
|
||||
|
||||
RUN \
|
||||
apt-get install -y git libgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
libgstreamer-plugins-good1.0-dev \
|
||||
libgstreamer-plugins-bad1.0-dev
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/tegra
|
||||
|
||||
RUN apt-get update && apt-get install -y ffmpeg
|
||||
|
||||
|
||||
ENTRYPOINT ["/init"]
|
||||
|
||||
# CMD ["python3", "--version"]
|
||||
|
||||
CMD ["python3", "-u", "-m", "frigate"]
|
||||
COPY frigate frigate/
|
||||
43
docker/Dockerfile.aarch64.l4t
Normal file
43
docker/Dockerfile.aarch64.l4t
Normal file
@ -0,0 +1,43 @@
|
||||
FROM frigate-wheels-l4t:latest as wheelsl4t
|
||||
FROM frigate-base-l4t
|
||||
LABEL maintainer "blakeb@blakeshome.com"
|
||||
|
||||
COPY --from=wheelsl4t /wheels/. /wheels/
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
# Install packages for apt repo
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install --no-install-recommends -y \
|
||||
git \
|
||||
# ffmpeg runtime dependencies
|
||||
libgomp1 \
|
||||
# runtime dependencies
|
||||
libopenexr24 \
|
||||
libgstreamer1.0-0 \
|
||||
libgstreamer-plugins-base1.0-0 \
|
||||
libopenblas-base \
|
||||
libjpeg-turbo8 \
|
||||
libpng16-16 \
|
||||
libtiff5 \
|
||||
libdc1394-22 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& (apt-get autoremove -y; apt-get autoclean -y)
|
||||
|
||||
# Install tensorrt and pycuda
|
||||
RUN pip3 install -U /wheels/*.whl
|
||||
|
||||
# Yolo4 model and plugins
|
||||
ADD .l4t_assets /yolo4/
|
||||
|
||||
# s6-overlay
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-aarch64-installer /tmp/
|
||||
RUN chmod +x /tmp/s6-overlay-aarch64-installer && /tmp/s6-overlay-aarch64-installer /
|
||||
|
||||
# Set up library path for the GStreamer
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/tegra
|
||||
|
||||
ENTRYPOINT ["/init"]
|
||||
|
||||
CMD ["python3", "-u", "-m", "frigate"]
|
||||
|
||||
COPY frigate frigate/
|
||||
@ -1,22 +1,35 @@
|
||||
ARG ARCH=amd64
|
||||
ARG WHEELS_VERSION
|
||||
ARG FFMPEG_VERSION
|
||||
ARG NGINX_VERSION
|
||||
ARG BASE_IMAGE=ubuntu:20.04
|
||||
FROM blakeblackshear/frigate-wheels:${WHEELS_VERSION}-${ARCH} as wheels
|
||||
FROM blakeblackshear/frigate-ffmpeg:${FFMPEG_VERSION}-${ARCH} as ffmpeg
|
||||
FROM blakeblackshear/frigate-nginx:${NGINX_VERSION} as nginx
|
||||
FROM frigate-web as web
|
||||
|
||||
FROM ubuntu:20.04
|
||||
FROM ${BASE_IMAGE}
|
||||
LABEL maintainer "blakeb@blakeshome.com"
|
||||
|
||||
COPY --from=ffmpeg /usr/local /usr/local/
|
||||
|
||||
COPY --from=wheels /wheels/. /wheels/
|
||||
|
||||
ENV FLASK_ENV=development
|
||||
# ENV FONTCONFIG_PATH=/etc/fonts
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# install jellyfin-ffmpeg
|
||||
RUN apt-get update && apt-get install -y wget libmysofa1 libpostproc55 librubberband2 libvidstab1.1 libzmq5 \
|
||||
libcdio-cdda2 libcdio-paranoia2 libxcb-shape0 libnorm1 libpgm-5.2-0 libsodium23 libass9 libbs2b0 libflite1 liblilv-0-0 \
|
||||
libavc1394-0 libcaca0 libiec61883-0 libjack-jackd2-0 libopenal1 libpulse0 libsdl2-2.0-0 libsndio7.0 libxv1 libavresample4
|
||||
|
||||
#ffmpeg arch: arm64, amd64, armhf
|
||||
ARG FFMPEG_ARCH=arm64
|
||||
ENV FFMPEG_VERSION=4.2.4
|
||||
RUN wget https://launchpad.net/ubuntu/+archive/primary/+files/libavutil56_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && dpkg -i libavutil56_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && \
|
||||
wget https://launchpad.net/ubuntu/+archive/primary/+files/libavcodec58_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && dpkg -i libavcodec58_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && \
|
||||
wget https://launchpad.net/ubuntu/+archive/primary/+files/libavfilter7_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && dpkg -i libavfilter7_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && \
|
||||
wget https://launchpad.net/ubuntu/+archive/primary/+files/libavdevice58_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && dpkg -i libavdevice58_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && \
|
||||
wget https://launchpad.net/ubuntu/+archive/primary/+files/ffmpeg_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && dpkg -i ffmpeg_${FFMPEG_VERSION}-1ubuntu0.1_${FFMPEG_ARCH}.deb && \
|
||||
rm *.deb
|
||||
|
||||
# Install packages for apt repo
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get upgrade -y \
|
||||
@ -36,6 +49,15 @@ RUN pip3 install \
|
||||
zeroconf \
|
||||
ws4py
|
||||
|
||||
RUN \
|
||||
apt-get update && apt-get install -y gstreamer1.0-plugins-base-apps gstreamer1.0-tools gstreamer1.0-alsa \
|
||||
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
|
||||
ibgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
libgstreamer-plugins-good1.0-dev \
|
||||
libgstreamer-plugins-bad1.0-dev
|
||||
|
||||
COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
|
||||
|
||||
# get model and labels
|
||||
@ -52,4 +74,4 @@ COPY --from=web /opt/frigate/build web/
|
||||
COPY docker/rootfs/ /
|
||||
|
||||
EXPOSE 5000
|
||||
EXPOSE 1935
|
||||
EXPOSE 1935
|
||||
@ -1,138 +0,0 @@
|
||||
ARG NGINX_VERSION
|
||||
FROM blakeblackshear/frigate-nginx-l4t:${NGINX_VERSION} as nginx
|
||||
FROM frigate-web as web
|
||||
FROM nvcr.io/nvidia/l4t-tensorrt:r8.0.1-runtime as wheels
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y \
|
||||
python3.8-dev \
|
||||
wget \
|
||||
# opencv dependencies
|
||||
build-essential cmake git pkg-config libgtk-3-dev
|
||||
|
||||
RUN apt-get -qq install -y \
|
||||
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
|
||||
libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev
|
||||
RUN apt-get -qq install -y \
|
||||
gfortran openexr libatlas-base-dev libssl-dev\
|
||||
libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev
|
||||
RUN apt-get -qq install -y \
|
||||
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
|
||||
# scipy dependencies
|
||||
gcc gfortran libopenblas-dev liblapack-dev cython
|
||||
|
||||
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
||||
&& python3 get-pip.py
|
||||
|
||||
RUN pip3 install scikit-build
|
||||
|
||||
RUN pip3 wheel --wheel-dir=/wheels \
|
||||
opencv-python-headless \
|
||||
numpy \
|
||||
imutils \
|
||||
scipy \
|
||||
psutil \
|
||||
Flask \
|
||||
paho-mqtt \
|
||||
PyYAML \
|
||||
matplotlib \
|
||||
click \
|
||||
setproctitle \
|
||||
peewee
|
||||
|
||||
FROM nvcr.io/nvidia/l4t-tensorrt:r8.0.1-runtime
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN \
|
||||
apt-get update && apt-get install -y gnupg
|
||||
RUN \
|
||||
apt-key adv --fetch-key https://repo.download.nvidia.com/jetson/jetson-ota-public.asc && \
|
||||
echo "deb https://repo.download.nvidia.com/jetson/ffmpeg main main" | tee -a /etc/apt/sources.list && \
|
||||
echo "deb-src https://repo.download.nvidia.com/jetson/ffmpeg main main" | tee -a /etc/apt/sources.list && \
|
||||
apt-get -qq update && \
|
||||
apt-get -qq install ffmpeg
|
||||
|
||||
COPY --from=wheels /wheels/. /wheels/
|
||||
|
||||
ENV FLASK_ENV=development
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get -qq install --no-install-recommends -y gnupg wget unzip tzdata libxml2
|
||||
|
||||
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
|
||||
&& python3 get-pip.py && \
|
||||
pip3 install -U /wheels/*.whl
|
||||
|
||||
|
||||
RUN \
|
||||
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn apt-key adv --fetch-keys https://packages.cloud.google.com/apt/doc/apt-key.gpg \
|
||||
&& 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 \
|
||||
&& apt-get -qq update
|
||||
|
||||
RUN \
|
||||
apt-get -qq install --no-install-recommends -y libedgetpu1-max python3-tflite-runtime python3-pycoral \
|
||||
&& rm -rf /var/lib/apt/lists/* /wheels \
|
||||
&& (apt-get autoremove -y; apt-get autoclean -y)
|
||||
|
||||
RUN pip3 install \
|
||||
peewee_migrate \
|
||||
pydantic \
|
||||
zeroconf \
|
||||
ws4py
|
||||
|
||||
|
||||
RUN \
|
||||
apt-get update && apt-get install -y gstreamer1.0-tools gstreamer1.0-alsa \
|
||||
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
|
||||
|
||||
RUN \
|
||||
apt-get install -y git libgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
libgstreamer-plugins-good1.0-dev \
|
||||
libgstreamer-plugins-bad1.0-dev
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/tegra
|
||||
|
||||
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
|
||||
|
||||
|
||||
COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
|
||||
COPY --from=web /opt/frigate/build /opt/frigate/web/
|
||||
|
||||
# install TRT dependencies
|
||||
RUN apt-get update && apt-get install -y git sudo
|
||||
ADD docker/l4t/ /l4t/
|
||||
RUN /l4t/install_pycuda.sh
|
||||
|
||||
# s6-overlay
|
||||
COPY docker/rootfs/ /
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-aarch64-installer /tmp/
|
||||
RUN chmod +x /tmp/s6-overlay-aarch64-installer && /tmp/s6-overlay-aarch64-installer /
|
||||
|
||||
|
||||
COPY labelmap.txt /labelmap.txt
|
||||
COPY detect.tflite /detect.tflite
|
||||
|
||||
|
||||
# edgetpu experiments
|
||||
RUN wget -q https://github.com/Azure/Azure-AI-Camp/releases/download/v1.0/yolov4-tiny.tflite -O /yolov4-tiny.tflite
|
||||
|
||||
|
||||
|
||||
# TRT Yolo4 Plugin
|
||||
ADD .l4t_assets /yolo4/
|
||||
|
||||
EXPOSE 5000
|
||||
EXPOSE 1935
|
||||
|
||||
WORKDIR /opt/frigate/
|
||||
|
||||
ADD frigate frigate/
|
||||
ADD migrations migrations/
|
||||
ENTRYPOINT ["/init"]
|
||||
CMD ["python3", "-u", "-m", "frigate"]
|
||||
@ -1,52 +0,0 @@
|
||||
FROM nvcr.io/nvidia/l4t-tensorrt:r8.0.1-runtime AS base
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get -yqq update && \
|
||||
apt-get install -yq --no-install-recommends ca-certificates expat libgomp1 && \
|
||||
apt-get autoremove -y && \
|
||||
apt-get clean -y
|
||||
|
||||
FROM base as build
|
||||
|
||||
ARG NGINX_VERSION=1.18.0
|
||||
ARG VOD_MODULE_VERSION=1.28
|
||||
ARG SECURE_TOKEN_MODULE_VERSION=1.4
|
||||
ARG RTMP_MODULE_VERSION=1.2.1
|
||||
|
||||
RUN cp /etc/apt/sources.list /etc/apt/sources.list~ \
|
||||
&& sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \
|
||||
&& apt-get update
|
||||
|
||||
RUN apt-get -yqq build-dep nginx
|
||||
|
||||
RUN apt-get -yqq install --no-install-recommends curl \
|
||||
&& mkdir /tmp/nginx \
|
||||
&& curl -sL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -C /tmp/nginx -zx --strip-components=1 \
|
||||
&& mkdir /tmp/nginx-vod-module \
|
||||
&& curl -sL https://github.com/kaltura/nginx-vod-module/archive/refs/tags/${VOD_MODULE_VERSION}.tar.gz | tar -C /tmp/nginx-vod-module -zx --strip-components=1 \
|
||||
# Patch MAX_CLIPS to allow more clips to be added than the default 128
|
||||
&& sed -i 's/MAX_CLIPS (128)/MAX_CLIPS (1080)/g' /tmp/nginx-vod-module/vod/media_set.h \
|
||||
&& mkdir /tmp/nginx-secure-token-module \
|
||||
&& curl -sL https://github.com/kaltura/nginx-secure-token-module/archive/refs/tags/${SECURE_TOKEN_MODULE_VERSION}.tar.gz | tar -C /tmp/nginx-secure-token-module -zx --strip-components=1 \
|
||||
&& mkdir /tmp/nginx-rtmp-module \
|
||||
&& curl -sL https://github.com/arut/nginx-rtmp-module/archive/refs/tags/v${RTMP_MODULE_VERSION}.tar.gz | tar -C /tmp/nginx-rtmp-module -zx --strip-components=1
|
||||
|
||||
WORKDIR /tmp/nginx
|
||||
|
||||
RUN ./configure --prefix=/usr/local/nginx \
|
||||
--with-file-aio \
|
||||
--with-http_sub_module \
|
||||
--with-http_ssl_module \
|
||||
--with-threads \
|
||||
--add-module=../nginx-vod-module \
|
||||
--add-module=../nginx-secure-token-module \
|
||||
--add-module=../nginx-rtmp-module \
|
||||
--with-cc-opt="-O3 -Wno-error=implicit-fallthrough"
|
||||
|
||||
RUN make && make install
|
||||
RUN rm -rf /usr/local/nginx/html /usr/local/nginx/conf/*.default
|
||||
|
||||
FROM base
|
||||
COPY --from=build /usr/local/nginx /usr/local/nginx
|
||||
ENTRYPOINT ["/usr/local/nginx/sbin/nginx"]
|
||||
CMD ["-g", "daemon off;"]
|
||||
34
docker/Dockerfile.wheels.l4t
Normal file
34
docker/Dockerfile.wheels.l4t
Normal file
@ -0,0 +1,34 @@
|
||||
FROM timongentzsch/l4t-ubuntu20-base:latest
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -yqq git python3.8 python3.8-dev python3-pip build-essential curl wget cmake
|
||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
|
||||
|
||||
RUN \
|
||||
EXT_PATH=~/external && \
|
||||
mkdir -p $EXT_PATH && cd $EXT_PATH && \
|
||||
git clone https://github.com/pybind/pybind11.git
|
||||
|
||||
RUN \
|
||||
PYTHON_VERSION=`python -c 'import platform;print(platform.python_version())'` && \
|
||||
EXT_PATH=~/external && \
|
||||
mkdir Python-${PYTHON_VERSION} && wget -qO- https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz | tar xvz --strip-components=1 -C Python-${PYTHON_VERSION} && \
|
||||
mkdir -p ${EXT_PATH}/python3.8/include && mv Python-${PYTHON_VERSION}/Include/* ${EXT_PATH}/python3.8/include/ && rm -rf Python-${PYTHON_VERSION} && \
|
||||
cp /usr/include/aarch64-linux-gnu/python3.8/pyconfig.h ~/external/python3.8/include/
|
||||
|
||||
RUN \
|
||||
mkdir /workspace && cd /workspace && git clone https://github.com/NVIDIA/TensorRT.git && \
|
||||
mkdir -p /workspace/TensorRT/python/include/onnx
|
||||
|
||||
WORKDIR /workspace/TensorRT/python
|
||||
# monkeypatch the environment
|
||||
RUN \
|
||||
cd /workspace/TensorRT/python && \
|
||||
echo "mkdir -p /wheels && pip3 wheel --wheel-dir=/wheels pycuda==2021.1\n"\
|
||||
"cp -r /usr/local/cuda-10.2/targets/aarch64-linux/include/* ./include/\n"\
|
||||
"cp -r /usr/include/aarch64-linux-gnu/* ./include/onnx/\n"\
|
||||
"EXT_PATH=/root/external PYTHON_MAJOR_VERSION=3 PYTHON_MINOR_VERSION=8 TARGET_ARCHITECTURE=aarch64 ./build.sh\n" \
|
||||
"cp /workspace/TensorRT/python/build/dist/*.whl /wheels\n" >> ./bootstrap.sh && \
|
||||
chmod +x ./bootstrap.sh
|
||||
|
||||
CMD ["/bin/bash", "./bootstrap.sh"]
|
||||
Loading…
Reference in New Issue
Block a user