2022-11-16 13:27:37 +01:00
|
|
|
# syntax=docker/dockerfile:1.2
|
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
FROM debian:11 AS base
|
|
|
|
|
|
|
|
FROM debian:11-slim AS slim-base
|
|
|
|
|
2022-11-20 14:34:12 +01:00
|
|
|
FROM blakeblackshear/frigate-nginx:1.0.2 AS nginx
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
|
|
|
|
FROM slim-base AS wget
|
|
|
|
ARG DEBIAN_FRONTEND
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y wget \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /rootfs
|
|
|
|
|
|
|
|
|
|
|
|
FROM wget AS go2rtc
|
|
|
|
ARG TARGETARCH
|
|
|
|
WORKDIR /rootfs/usr/local/go2rtc/bin
|
|
|
|
RUN wget -qO go2rtc "https://github.com/AlexxIT/go2rtc/releases/download/v0.1-rc.3/go2rtc_linux_${TARGETARCH}" \
|
|
|
|
&& chmod +x go2rtc
|
|
|
|
|
|
|
|
|
|
|
|
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 .
|
|
|
|
|
|
|
|
|
|
|
|
FROM wget AS s6-overlay
|
2022-02-22 04:11:10 +01:00
|
|
|
ARG TARGETARCH
|
2022-11-22 02:31:39 +01:00
|
|
|
RUN --mount=type=bind,source=docker/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \
|
|
|
|
/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 \
|
2022-07-04 16:06:26 +02: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 14:43:30 +01: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 04:11:10 +01: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 14:21:21 +02:00
|
|
|
COPY requirements.txt /requirements.txt
|
|
|
|
RUN pip3 install -r requirements.txt
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2022-04-12 14:21:21 +02:00
|
|
|
COPY requirements-wheels.txt /requirements-wheels.txt
|
2022-04-12 15:30:55 +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/ /
|
|
|
|
COPY --from=s6-overlay /rootfs/ /
|
|
|
|
COPY --from=models /rootfs/ /
|
|
|
|
COPY docker/rootfs/ /
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
|
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
ENV FLASK_ENV="development"
|
2022-02-18 14:43:30 +01:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
|
2022-04-26 14:18:13 +02:00
|
|
|
|
2022-11-22 02:31:39 +01:00
|
|
|
# Install dependencies
|
|
|
|
RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh \
|
|
|
|
/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 \
|
|
|
|
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
|
|
|
|
EXPOSE 1935
|
2022-11-02 12:36:09 +01:00
|
|
|
EXPOSE 8554
|
|
|
|
EXPOSE 8555
|
2022-02-18 14:43:30 +01:00
|
|
|
|
|
|
|
ENTRYPOINT ["/init"]
|
|
|
|
|
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
|
|
|
|
|
|
|
# Install Node 16
|
2022-11-22 02:31:39 +01:00
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install wget -y \
|
|
|
|
&& wget -qO- https://deb.nodesource.com/setup_16.x | bash - \
|
2022-11-20 14:34:12 +01:00
|
|
|
&& apt-get install -y nodejs \
|
2022-11-22 02:31:39 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
2022-11-20 14:34:12 +01:00
|
|
|
&& npm install -g npm@9
|
|
|
|
|
|
|
|
WORKDIR /workspace/frigate
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install make -y \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
RUN --mount=type=bind,source=./requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \
|
|
|
|
pip3 install -r requirements-dev.txt
|
|
|
|
|
|
|
|
CMD ["sleep", "infinity"]
|
|
|
|
|
|
|
|
|
|
|
|
# Frigate web build
|
2022-11-24 03:00:45 +01:00
|
|
|
# force this to run on amd64 because QEMU is painfully slow
|
|
|
|
FROM --platform=linux/amd64 node:16 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/ ./
|
|
|
|
RUN npm run build
|
|
|
|
|
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
|
|
|
|
FROM deps
|
|
|
|
|
|
|
|
WORKDIR /opt/frigate/
|
|
|
|
COPY --from=rootfs / /
|
|
|
|
|
2022-02-18 14:43:30 +01:00
|
|
|
CMD ["python3", "-u", "-m", "frigate"]
|