mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Make main frigate build non rpi specific and build rpi using base image
This commit is contained in:
parent
c5b8d13beb
commit
2e57e92dcd
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@ -44,24 +44,41 @@ jobs:
|
|||||||
run: make version
|
run: make version
|
||||||
- name: Create short sha
|
- name: Create short sha
|
||||||
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||||
- name: Build and push
|
- name: Create base image path
|
||||||
|
run: echo "BASE_IMAGE=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}" >> $GITHUB_ENV
|
||||||
|
- name: Build and push main build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
file: {context}/docker/build/main/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
target: frigate
|
target: frigate
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}
|
${{ env.BASE_IMAGE }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
- name: Build and push RPi build
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: {context}/docker/build/rpi/Dockerfile
|
||||||
|
push: true
|
||||||
|
platforms: linux/arm64
|
||||||
|
target: frigate-rpi
|
||||||
|
build-args: |
|
||||||
|
BASE_IMAGE=${{ env.BASE_IMAGE }}
|
||||||
|
tags: |
|
||||||
|
${{ env.BASE_IMAGE }}-rpi
|
||||||
|
cache-from: type=gha
|
||||||
- name: Build and push TensorRT
|
- name: Build and push TensorRT
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
file: {context}/docker/build/main/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
target: frigate-tensorrt
|
target: frigate-tensorrt
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-tensorrt
|
${{ env.BASE_IMAGE }}-tensorrt
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
|
|||||||
19
Makefile
19
Makefile
@ -10,24 +10,27 @@ version:
|
|||||||
echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py
|
echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py
|
||||||
|
|
||||||
local: version
|
local: version
|
||||||
docker buildx build --target=frigate --tag frigate:latest --load .
|
docker buildx build --target=frigate --tag frigate:latest --load --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
|
local-rpi: version local
|
||||||
|
docker buildx build --tag frigate:latest-rpi --build-arg BASE_IMAGE=frigate:latest --load --file docker/build/rpi/Dockerfile .
|
||||||
|
|
||||||
local-trt: version
|
local-trt: version
|
||||||
docker buildx build --target=frigate-tensorrt --tag frigate:latest-tensorrt --load .
|
docker buildx build --target=frigate-tensorrt --tag frigate:latest-tensorrt --load --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
amd64:
|
amd64:
|
||||||
docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) .
|
docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/build/main/Dockerfile .
|
||||||
docker buildx build --platform linux/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH)-tensorrt .
|
docker buildx build --platform linux/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH)-tensorrt --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
arm64:
|
arm64:
|
||||||
docker buildx build --platform linux/arm64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) .
|
docker buildx build --platform linux/arm64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
build: version amd64 arm64
|
build: version amd64 arm64
|
||||||
docker buildx build --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) .
|
docker buildx build --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
push: build
|
push: build
|
||||||
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) .
|
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) --file docker/build/main/Dockerfile .
|
||||||
docker buildx build --push --platform linux/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt .
|
docker buildx build --push --platform linux/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt --file docker/build/main/Dockerfile .
|
||||||
|
|
||||||
run: local
|
run: local
|
||||||
docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest
|
docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest
|
||||||
|
|||||||
@ -34,32 +34,6 @@ RUN wget -qO go2rtc "https://github.com/AlexxIT/go2rtc/releases/download/v1.6.0/
|
|||||||
&& chmod +x go2rtc
|
&& chmod +x go2rtc
|
||||||
|
|
||||||
|
|
||||||
####
|
|
||||||
#
|
|
||||||
# OpenVino Support
|
|
||||||
#
|
|
||||||
# 1. Download and convert a model from Intel's Public Open Model Zoo
|
|
||||||
# 2. Build libUSB without udev to handle NCS2 enumeration
|
|
||||||
#
|
|
||||||
####
|
|
||||||
# Download and Convert OpenVino model
|
|
||||||
FROM base_amd64 AS ov-converter
|
|
||||||
ARG DEBIAN_FRONTEND
|
|
||||||
|
|
||||||
# Install OpenVino Runtime and Dev library
|
|
||||||
COPY requirements-ov.txt /requirements-ov.txt
|
|
||||||
RUN apt-get -qq update \
|
|
||||||
&& apt-get -qq install -y wget python3 python3-distutils \
|
|
||||||
&& 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
|
|
||||||
RUN mkdir /models \
|
|
||||||
&& cd /models && omz_downloader --name ssdlite_mobilenet_v2 \
|
|
||||||
&& cd /models && omz_converter --name ssdlite_mobilenet_v2 --precision FP16
|
|
||||||
|
|
||||||
|
|
||||||
# libUSB - No Udev
|
# libUSB - No Udev
|
||||||
FROM wget as libusb-build
|
FROM wget as libusb-build
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
@ -94,10 +68,6 @@ FROM wget AS models
|
|||||||
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 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
|
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 .
|
COPY labelmap.txt .
|
||||||
# Copy OpenVino model
|
|
||||||
COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model
|
|
||||||
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
|
|
||||||
# Get Audio Model and labels
|
# 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
|
RUN wget -qO cpu_audio_model.tflite https://tfhub.dev/google/lite-model/yamnet/classification/tflite/1?lite-format=tflite
|
||||||
COPY audio-labelmap.txt .
|
COPY audio-labelmap.txt .
|
||||||
@ -120,7 +90,7 @@ RUN apt-get -qq update \
|
|||||||
gnupg \
|
gnupg \
|
||||||
wget \
|
wget \
|
||||||
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E \
|
&& 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 \
|
&& echo "deb http://deb.debian.org/debian bullseye main contrib non-free" | tee /etc/apt/sources.list.d/raspi.list \
|
||||||
&& apt-get -qq update \
|
&& apt-get -qq update \
|
||||||
&& apt-get -qq install -y \
|
&& apt-get -qq install -y \
|
||||||
python3 \
|
python3 \
|
||||||
@ -181,7 +151,7 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
|
|||||||
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
|
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh \
|
RUN --mount=type=bind,source=docker/build/main/install_deps.sh,target=/deps/install_deps.sh \
|
||||||
/deps/install_deps.sh
|
/deps/install_deps.sh
|
||||||
|
|
||||||
RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
|
RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
|
||||||
@ -41,11 +41,10 @@ fi
|
|||||||
|
|
||||||
# ffmpeg -> arm64
|
# ffmpeg -> arm64
|
||||||
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
||||||
# add raspberry pi repo
|
mkdir -p /usr/lib/btbn-ffmpeg
|
||||||
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
|
wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz"
|
||||||
echo "deb [signed-by=/usr/share/keyrings/raspbian.gpg] https://archive.raspberrypi.org/debian/ bullseye main" | tee /etc/apt/sources.list.d/raspi.list
|
tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1
|
||||||
apt-get -qq update
|
rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay
|
||||||
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# arch specific packages
|
# arch specific packages
|
||||||
14
docker/build/rpi/Dockerfile
Normal file
14
docker/build/rpi/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
|
||||||
|
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ARG BASE_IMAGE
|
||||||
|
|
||||||
|
FROM ${BASE_IMAGE} as base
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN rm -rf /usr/lib/btbn-ffmpeg/
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN --mount=type=bind,source=docker/build/rpi/install_deps.sh,target=/deps/install_deps.sh \
|
||||||
|
/deps/install_deps.sh
|
||||||
30
docker/build/rpi/install_deps.sh
Executable file
30
docker/build/rpi/install_deps.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
apt-get -qq update
|
||||||
|
|
||||||
|
apt-get -qq install --no-install-recommends -y \
|
||||||
|
apt-transport-https \
|
||||||
|
gnupg \
|
||||||
|
wget \
|
||||||
|
procps vainfo \
|
||||||
|
unzip locales tzdata libxml2 xz-utils \
|
||||||
|
python3-pip \
|
||||||
|
curl \
|
||||||
|
jq \
|
||||||
|
nethogs
|
||||||
|
|
||||||
|
mkdir -p -m 600 /root/.gnupg
|
||||||
|
|
||||||
|
# enable non-free repo
|
||||||
|
sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list
|
||||||
|
|
||||||
|
# ffmpeg -> arm64
|
||||||
|
if [[ "${TARGETARCH}" == "arm64" ]]; then
|
||||||
|
# add raspberry pi repo
|
||||||
|
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/raspbian.gpg] https://archive.raspberrypi.org/debian/ bullseye main" | tee /etc/apt/sources.list.d/raspi.list
|
||||||
|
apt-get -qq update
|
||||||
|
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg
|
||||||
|
fi
|
||||||
Loading…
Reference in New Issue
Block a user