diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93b084a8d..2ef492a70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,10 +44,19 @@ jobs: run: make version - name: Create short sha run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV - - name: Build and push + - uses: docker/metadata-action@v4 + id: metadata + with: + images: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }} + # avoid overwriting the latest tag because metadata-action does not add a suffix to it + flavor: latest=false,suffix=-${{ matrix.platform }} + # The majority of users running arm64 are rpi users, so the rpi + # build should be the primary arm64 image + - name: Build and push standard build uses: docker/build-push-action@v4 with: context: . + file: docker/main/Dockerfile push: true platforms: linux/amd64,linux/arm64 target: frigate @@ -55,13 +64,28 @@ jobs: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }} cache-from: type=gha cache-to: type=gha,mode=max - - name: Build and push TensorRT - uses: docker/build-push-action@v4 + - name: Build and push RPi build + uses: docker/bake-action@v3 with: - context: . push: true - platforms: linux/amd64 - target: frigate-tensorrt - tags: | - ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-tensorrt - cache-from: type=gha + targets: rpi + files: docker/rpi/rpi.hcl + set: | + rpi.tags=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-rpi + *.cache-from=type=gha + - name: Build and push TensorRT + uses: docker/bake-action@v3 + with: + push: true + targets: tensorrt + files: docker/tensorrt/trt.hcl + set: | + tensorrt.tags=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-tensorrt + *.cache-from=type=gha + - name: Assemble and push default build + uses: int128/docker-manifest-create-action@v1 + with: + tags: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }} + suffixes: | + -amd64 + -rpi \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7e97cfb6c..3b094ca90 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -71,7 +71,7 @@ jobs: - name: Install requirements run: | python3 -m pip install -U pip - python3 -m pip install -r requirements-dev.txt + python3 -m pip install -r docker/main/requirements-dev.txt - name: Check black run: | black --check --diff frigate migrations docker *.py diff --git a/Makefile b/Makefile index 9035a58f4..2cd831670 100644 --- a/Makefile +++ b/Makefile @@ -3,31 +3,34 @@ default_target: local COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1) VERSION = 0.13.0 IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate +GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) CURRENT_UID := $(shell id -u) CURRENT_GID := $(shell id -g) +BOARDS= #Initialized empty + +include docker/*/*.mk + +build-boards: $(BOARDS:%=build-%) + +push-boards: $(BOARDS:%=push-%) version: echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py local: version - docker buildx build --target=frigate --tag frigate:latest --load . - -local-trt: version - docker buildx build --target=frigate-tensorrt --tag frigate:latest-tensorrt --load . + docker buildx build --target=frigate --tag frigate:latest --load --file docker/main/Dockerfile . amd64: - docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) . - docker buildx build --platform linux/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH)-tensorrt . + docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . 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/main/Dockerfile . 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/main/Dockerfile . -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/amd64 --target=frigate-tensorrt --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt . +push: push-boards + docker buildx build --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) --file docker/main/Dockerfile . run: local docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest diff --git a/docker-compose.yml b/docker-compose.yml index cf3613484..b16f652f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: shm_size: "256mb" build: context: . + dockerfile: docker/main/Dockerfile # Use target devcontainer-trt for TensorRT dev target: devcontainer deploy: diff --git a/Dockerfile b/docker/main/Dockerfile similarity index 75% rename from Dockerfile rename to docker/main/Dockerfile index 8a68369f1..06bc71c06 100644 --- a/Dockerfile +++ b/docker/main/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1.2 +# syntax=docker/dockerfile:1.4 # https://askubuntu.com/questions/972516/debian-frontend-environment-variable ARG DEBIAN_FRONTEND=noninteractive @@ -23,7 +23,7 @@ ENV CCACHE_MAXSIZE 2G # bind /var/cache/apt to tmpfs to speed up nginx build RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \ - --mount=type=bind,source=docker/build_nginx.sh,target=/deps/build_nginx.sh \ + --mount=type=bind,source=docker/main/build_nginx.sh,target=/deps/build_nginx.sh \ --mount=type=cache,target=/root/.ccache \ /deps/build_nginx.sh @@ -47,7 +47,7 @@ FROM base_amd64 AS ov-converter ARG DEBIAN_FRONTEND # Install OpenVino Runtime and Dev library -COPY requirements-ov.txt /requirements-ov.txt +COPY docker/main/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 \ @@ -105,7 +105,7 @@ COPY audio-labelmap.txt . FROM wget AS s6-overlay ARG TARGETARCH -RUN --mount=type=bind,source=docker/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \ +RUN --mount=type=bind,source=docker/main/install_s6_overlay.sh,target=/deps/install_s6_overlay.sh \ /deps/install_s6_overlay.sh @@ -119,8 +119,8 @@ RUN apt-get -qq update \ apt-transport-https \ gnupg \ wget \ - && 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 \ + && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 \ + && 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 install -y \ python3 \ @@ -140,21 +140,12 @@ RUN apt-get -qq update \ RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ && python3 get-pip.py "pip" -COPY requirements.txt /requirements.txt +COPY docker/main/requirements.txt /requirements.txt RUN pip3 install -r requirements.txt -COPY requirements-wheels.txt /requirements-wheels.txt +COPY docker/main/requirements-wheels.txt /requirements-wheels.txt RUN pip3 wheel --wheel-dir=/wheels -r requirements-wheels.txt -# Make this a separate target so it can be built/cached optionally -FROM wheels as trt-wheels -ARG DEBIAN_FRONTEND -ARG TARGETARCH - -# Add TensorRT wheels to another folder -COPY requirements-tensorrt.txt /requirements-tensorrt.txt -RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r requirements-tensorrt.txt - # Collect deps in a single layer FROM scratch AS deps-rootfs @@ -163,7 +154,7 @@ COPY --from=go2rtc /rootfs/ / COPY --from=libusb-build /usr/local/lib /usr/local/lib COPY --from=s6-overlay /rootfs/ / COPY --from=models /rootfs/ / -COPY docker/rootfs/ / +COPY docker/main/rootfs/ / # Frigate deps (ffmpeg, python, nginx, go2rtc, s6-overlay, etc) @@ -181,7 +172,7 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}" # Install dependencies -RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh \ +RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \ /deps/install_deps.sh RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \ @@ -207,7 +198,7 @@ FROM deps AS devcontainer # 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 -COPY docker/fake_frigate_run /etc/s6-overlay/s6-rc.d/frigate/run +COPY docker/main/fake_frigate_run /etc/s6-overlay/s6-rc.d/frigate/run # Create symbolic link to the frigate source code, as go2rtc's create_config.sh uses it RUN mkdir -p /opt/frigate \ @@ -227,7 +218,7 @@ 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 \ +RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \ pip3 install -r requirements-dev.txt CMD ["sleep", "infinity"] @@ -259,36 +250,3 @@ FROM deps AS frigate WORKDIR /opt/frigate/ COPY --from=rootfs / / - -# Build TensorRT-specific library -FROM nvcr.io/nvidia/tensorrt:23.03-py3 AS trt-deps - -RUN --mount=type=bind,source=docker/support/tensorrt_detector/tensorrt_libyolo.sh,target=/tensorrt_libyolo.sh \ - /tensorrt_libyolo.sh - -# Frigate w/ TensorRT Support as separate image -FROM frigate AS frigate-tensorrt - -#Disable S6 Global timeout -ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 - -ENV TRT_VER=8.5.3 -ENV YOLO_MODELS="yolov7-tiny-416" - -COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so -COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos -COPY docker/support/tensorrt_detector/rootfs/ / - -RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ - pip3 install -U /deps/trt-wheels/*.whl && \ - ldconfig - -# Dev Container w/ TRT -FROM devcontainer AS devcontainer-trt - -COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so -COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos -COPY docker/support/tensorrt_detector/rootfs/ / -COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so -RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ - pip3 install -U /deps/trt-wheels/*.whl diff --git a/docker/build_nginx.sh b/docker/main/build_nginx.sh similarity index 100% rename from docker/build_nginx.sh rename to docker/main/build_nginx.sh diff --git a/docker/fake_frigate_run b/docker/main/fake_frigate_run similarity index 100% rename from docker/fake_frigate_run rename to docker/main/fake_frigate_run diff --git a/docker/install_deps.sh b/docker/main/install_deps.sh similarity index 86% rename from docker/install_deps.sh rename to docker/main/install_deps.sh index 7d5242d83..9eb784ec8 100755 --- a/docker/install_deps.sh +++ b/docker/main/install_deps.sh @@ -41,11 +41,10 @@ fi # 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 + mkdir -p /usr/lib/btbn-ffmpeg + 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" + tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 + rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay fi # arch specific packages diff --git a/docker/install_s6_overlay.sh b/docker/main/install_s6_overlay.sh similarity index 100% rename from docker/install_s6_overlay.sh rename to docker/main/install_s6_overlay.sh diff --git a/requirements-dev.txt b/docker/main/requirements-dev.txt similarity index 100% rename from requirements-dev.txt rename to docker/main/requirements-dev.txt diff --git a/requirements-ov.txt b/docker/main/requirements-ov.txt similarity index 100% rename from requirements-ov.txt rename to docker/main/requirements-ov.txt diff --git a/requirements-wheels.txt b/docker/main/requirements-wheels.txt similarity index 100% rename from requirements-wheels.txt rename to docker/main/requirements-wheels.txt diff --git a/requirements.txt b/docker/main/requirements.txt similarity index 100% rename from requirements.txt rename to docker/main/requirements.txt diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/consumer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/consumer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/consumer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/consumer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/dependencies.d/log-prepare b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/dependencies.d/log-prepare similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/dependencies.d/log-prepare rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/dependencies.d/log-prepare diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/pipeline-name b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/pipeline-name similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/pipeline-name rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/pipeline-name diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate-log/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/go2rtc b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/go2rtc similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/go2rtc rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/go2rtc diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/finish diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/producer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/producer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/producer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/producer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/timeout-kill b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/timeout-kill similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/timeout-kill rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/timeout-kill diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/frigate/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/dependencies.d/go2rtc b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/dependencies.d/go2rtc similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/dependencies.d/go2rtc rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/dependencies.d/go2rtc diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/finish similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/finish rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/finish diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/producer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/producer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/producer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/producer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/timeout-kill b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/timeout-kill similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/timeout-kill rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/timeout-kill diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-healthcheck/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/consumer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/consumer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/consumer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/consumer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/dependencies.d/log-prepare b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/dependencies.d/log-prepare similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/dependencies.d/log-prepare rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/dependencies.d/log-prepare diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/pipeline-name b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/pipeline-name similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/pipeline-name rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/pipeline-name diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc-log/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/dependencies.d/base b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/dependencies.d/base similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/dependencies.d/base rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/dependencies.d/base diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/finish diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/producer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/producer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/producer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/producer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/timeout-kill b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/timeout-kill similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/timeout-kill rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/timeout-kill diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/dependencies.d/base b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/dependencies.d/base similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/dependencies.d/base rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/dependencies.d/base diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/up b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/up similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/up rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/up diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/consumer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/consumer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/consumer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/consumer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/dependencies.d/log-prepare b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/dependencies.d/log-prepare similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/dependencies.d/log-prepare rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/dependencies.d/log-prepare diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/pipeline-name b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/pipeline-name similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/pipeline-name rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/pipeline-name diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx-log/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/frigate b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/frigate similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/frigate rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/frigate diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/producer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/producer-for similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/producer-for rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/producer-for diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/run rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/timeout-kill b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/timeout-kill similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/timeout-kill rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/timeout-kill diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/type similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/nginx/type rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/type diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/frigate-pipeline b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/frigate-pipeline similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/frigate-pipeline rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/frigate-pipeline diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/go2rtc-pipeline b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/go2rtc-pipeline similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/go2rtc-pipeline rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/go2rtc-pipeline diff --git a/docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx-pipeline b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx-pipeline similarity index 100% rename from docker/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx-pipeline rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx-pipeline diff --git a/docker/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py similarity index 100% rename from docker/rootfs/usr/local/go2rtc/create_config.py rename to docker/main/rootfs/usr/local/go2rtc/create_config.py diff --git a/docker/rootfs/usr/local/nginx/conf/nginx.conf b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf similarity index 100% rename from docker/rootfs/usr/local/nginx/conf/nginx.conf rename to docker/main/rootfs/usr/local/nginx/conf/nginx.conf diff --git a/docker/rpi/Dockerfile b/docker/rpi/Dockerfile new file mode 100644 index 000000000..581ca7ff8 --- /dev/null +++ b/docker/rpi/Dockerfile @@ -0,0 +1,16 @@ +# syntax=docker/dockerfile:1.4 + +# https://askubuntu.com/questions/972516/debian-frontend-environment-variable +ARG DEBIAN_FRONTEND=noninteractive + +FROM deps AS rpi-deps +ARG TARGETARCH + +RUN rm -rf /usr/lib/btbn-ffmpeg/ + +# Install dependencies +RUN --mount=type=bind,source=docker/rpi/install_deps.sh,target=/deps/install_deps.sh \ + /deps/install_deps.sh + +WORKDIR /opt/frigate/ +COPY --from=rootfs / / diff --git a/docker/rpi/install_deps.sh b/docker/rpi/install_deps.sh new file mode 100755 index 000000000..9716623ca --- /dev/null +++ b/docker/rpi/install_deps.sh @@ -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 diff --git a/docker/rpi/rpi.hcl b/docker/rpi/rpi.hcl new file mode 100644 index 000000000..66f97c16d --- /dev/null +++ b/docker/rpi/rpi.hcl @@ -0,0 +1,20 @@ +target deps { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/arm64"] + target = "deps" +} + +target rootfs { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/arm64"] + target = "rootfs" +} + +target rpi { + dockerfile = "docker/rpi/Dockerfile" + contexts = { + deps = "target:deps", + rootfs = "target:rootfs" + } + platforms = ["linux/arm64"] +} \ No newline at end of file diff --git a/docker/rpi/rpi.mk b/docker/rpi/rpi.mk new file mode 100644 index 000000000..c1282b011 --- /dev/null +++ b/docker/rpi/rpi.mk @@ -0,0 +1,10 @@ +BOARDS += rpi + +local-rpi: version + docker buildx bake --load --file=docker/rpi/rpi.hcl --set rpi.tags=frigate:latest-rpi rpi + +build-rpi: version + docker buildx bake --file=docker/rpi/rpi.hcl --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi rpi + +push-rpi: build-rpi + docker buildx bake --push --file=docker/rpi/rpi.hcl --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi rpi \ No newline at end of file diff --git a/docker/tensorrt/Dockerfile b/docker/tensorrt/Dockerfile new file mode 100644 index 000000000..564cc3b5b --- /dev/null +++ b/docker/tensorrt/Dockerfile @@ -0,0 +1,49 @@ +# syntax=docker/dockerfile:1.4 + +# https://askubuntu.com/questions/972516/debian-frontend-environment-variable +ARG DEBIAN_FRONTEND=noninteractive + +# Make this a separate target so it can be built/cached optionally +FROM wheels as trt-wheels +ARG DEBIAN_FRONTEND +ARG TARGETARCH + +# Add TensorRT wheels to another folder +COPY docker/tensorrt/requirements.txt /requirements-tensorrt.txt +RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt + +# Build TensorRT-specific library +FROM nvcr.io/nvidia/tensorrt:23.03-py3 AS trt-deps + +RUN --mount=type=bind,source=docker/tensorrt/detector/tensorrt_libyolo.sh,target=/tensorrt_libyolo.sh \ + /tensorrt_libyolo.sh + +# Frigate w/ TensorRT Support as separate image +FROM deps AS frigate-tensorrt + +#Disable S6 Global timeout +ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 + +ENV TRT_VER=8.5.3 +ENV YOLO_MODELS="yolov7-tiny-416" + +COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so +COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos +COPY docker/tensorrt/detector/rootfs/ / + +RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ + pip3 install -U /deps/trt-wheels/*.whl && \ + ldconfig + +WORKDIR /opt/frigate/ +COPY --from=rootfs / / + +# Dev Container w/ TRT +FROM devcontainer AS devcontainer-trt + +COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so +COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos +COPY docker/tensorrt/detector/rootfs/ / +COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so +RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ + pip3 install -U /deps/trt-wheels/*.whl diff --git a/docker/support/tensorrt_detector/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf b/docker/tensorrt/detector/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf rename to docker/tensorrt/detector/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf diff --git a/docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/trt-model-prepare b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/trt-model-prepare similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/trt-model-prepare rename to docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/trt-model-prepare diff --git a/docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/dependencies.d/base b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/dependencies.d/base similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/dependencies.d/base rename to docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/dependencies.d/base diff --git a/docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run rename to docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run diff --git a/docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/type b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/type similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/type rename to docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/type diff --git a/docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/up b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/up similarity index 100% rename from docker/support/tensorrt_detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/up rename to docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/up diff --git a/docker/support/tensorrt_detector/tensorrt_libyolo.sh b/docker/tensorrt/detector/tensorrt_libyolo.sh similarity index 100% rename from docker/support/tensorrt_detector/tensorrt_libyolo.sh rename to docker/tensorrt/detector/tensorrt_libyolo.sh diff --git a/requirements-tensorrt.txt b/docker/tensorrt/requirements.txt similarity index 100% rename from requirements-tensorrt.txt rename to docker/tensorrt/requirements.txt diff --git a/docker/tensorrt/trt.hcl b/docker/tensorrt/trt.hcl new file mode 100644 index 000000000..589d0b73b --- /dev/null +++ b/docker/tensorrt/trt.hcl @@ -0,0 +1,48 @@ +target deps { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/amd64"] + target = "deps" +} + +target rootfs { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/amd64"] + target = "rootfs" +} + +target wheels { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/amd64"] + target = "wheels" +} + +target devcontainer { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/amd64"] + target = "devcontainer" +} + +target tensorrt { + dockerfile = "docker/tensorrt/Dockerfile" + context = "." + contexts = { + deps = "target:deps", + rootfs = "target:rootfs" + wheels = "target:wheels" + } + platforms = ["linux/amd64"] + target = "frigate-tensorrt" +} + +target devcontainer-trt { + dockerfile = "docker/tensorrt/Dockerfile" + context = "." + contexts = { + deps = "target:deps", + rootfs = "target:rootfs" + wheels = "target:wheels" + devcontainer = "target:devcontainer" + } + platforms = ["linux/amd64"] + target = "devcontainer-trt" +} \ No newline at end of file diff --git a/docker/tensorrt/trt.mk b/docker/tensorrt/trt.mk new file mode 100644 index 000000000..bc01a83b3 --- /dev/null +++ b/docker/tensorrt/trt.mk @@ -0,0 +1,10 @@ +BOARDS += trt + +local-trt: version + docker buildx bake --load --file=docker/tensorrt/trt.hcl --set tensorrt.tags=frigate:latest-tensorrt tensorrt + +build-trt: + docker buildx bake --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt tensorrt + +push-trt: build-trt + docker buildx bake --push --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt tensorrt \ No newline at end of file diff --git a/docs/docs/configuration/hardware_acceleration.md b/docs/docs/configuration/hardware_acceleration.md index 90ede4e54..cb042c860 100644 --- a/docs/docs/configuration/hardware_acceleration.md +++ b/docs/docs/configuration/hardware_acceleration.md @@ -5,7 +5,9 @@ title: Hardware Acceleration It is recommended to update your configuration to enable hardware accelerated decoding in ffmpeg. Depending on your system, these parameters may not be compatible. More information on hardware accelerated decoding for ffmpeg can be found here: https://trac.ffmpeg.org/wiki/HWAccelIntro -### Raspberry Pi 3/4 +# Officially Supported + +## Raspberry Pi 3/4 Ensure you increase the allocated RAM for your GPU to at least 128 (raspi-config > Performance Options > GPU Memory). **NOTICE**: If you are using the addon, you may need to turn off `Protection mode` for hardware acceleration. @@ -29,9 +31,9 @@ docker run -d \ ::: -### Intel-based CPUs +## Intel-based CPUs -#### Via VAAPI +### Via VAAPI VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. VAAPI is recommended for all generations of Intel-based CPUs if QSV does not work. @@ -42,25 +44,25 @@ ffmpeg: **NOTICE**: With some of the processors, like the J4125, the default driver `iHD` doesn't seem to work correctly for hardware acceleration. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars). -#### Via Quicksync (>=10th Generation only) +### Via Quicksync (>=10th Generation only) QSV must be set specifically based on the video encoding of the stream. -##### H.264 streams +#### H.264 streams ```yaml ffmpeg: hwaccel_args: preset-intel-qsv-h264 ``` -##### H.265 streams +#### H.265 streams ```yaml ffmpeg: hwaccel_args: preset-intel-qsv-h265 ``` -#### Configuring Intel GPU Stats in Docker +### Configuring Intel GPU Stats in Docker Additional configuration is needed for the Docker container to be able to access the `intel_gpu_top` command for GPU stats. Three possible changes can be made: @@ -68,11 +70,11 @@ Additional configuration is needed for the Docker container to be able to access 2. Adding the `CAP_PERFMON` capability. 3. Setting the `perf_event_paranoid` low enough to allow access to the performance event system. -##### Run as privileged +#### Run as privileged This method works, but it gives more permissions to the container than are actually needed. -###### Docker Compose - Privileged +##### Docker Compose - Privileged ```yaml services: @@ -82,7 +84,7 @@ services: privileged: true ``` -###### Docker Run CLI - Privileged +##### Docker Run CLI - Privileged ```bash docker run -d \ @@ -92,11 +94,11 @@ docker run -d \ ghcr.io/blakeblackshear/frigate:stable ``` -##### CAP_PERFMON +#### CAP_PERFMON Only recent versions of Docker support the `CAP_PERFMON` capability. You can test to see if yours supports it by running: `docker run --cap-add=CAP_PERFMON hello-world` -###### Docker Compose - CAP_PERFMON +##### Docker Compose - CAP_PERFMON ```yaml services: @@ -107,7 +109,7 @@ services: - CAP_PERFMON ``` -###### Docker Run CLI - CAP_PERFMON +##### Docker Run CLI - CAP_PERFMON ```bash docker run -d \ @@ -117,7 +119,7 @@ docker run -d \ ghcr.io/blakeblackshear/frigate:stable ``` -##### perf_event_paranoid +#### perf_event_paranoid _Note: This setting must be changed for the entire system._ @@ -125,7 +127,7 @@ For more information on the various values across different distributions, see h Depending on your OS and kernel configuration, you may need to change the `/proc/sys/kernel/perf_event_paranoid` kernel tunable. You can test the change by running `sudo sh -c 'echo 2 >/proc/sys/kernel/perf_event_paranoid'` which will persist until a reboot. Make it permanent by running `sudo sh -c 'echo kernel.perf_event_paranoid=1 >> /etc/sysctl.d/local.conf'` -### AMD/ATI GPUs (Radeon HD 2000 and newer GPUs) via libva-mesa-driver +## AMD/ATI GPUs (Radeon HD 2000 and newer GPUs) via libva-mesa-driver VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. @@ -136,7 +138,7 @@ ffmpeg: hwaccel_args: preset-vaapi ``` -### NVIDIA GPUs +## NVIDIA GPUs While older GPUs may work, it is recommended to use modern, supported GPUs. NVIDIA provides a [matrix of supported GPUs and features](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new). If your card is on the list and supports CUVID/NVDEC, it will most likely work with Frigate for decoding. However, you must also use [a driver version that will work with FFmpeg](https://github.com/FFmpeg/nv-codec-headers/blob/master/README). Older driver versions may be missing symbols and fail to work, and older cards are not supported by newer driver versions. The only way around this is to [provide your own FFmpeg](/configuration/advanced#custom-ffmpeg-build) that will work with your driver version, but this is unsupported and may not work well if at all. @@ -144,11 +146,11 @@ A more complete list of cards and their compatible drivers is available in the [ If your distribution does not offer NVIDIA driver packages, you can [download them here](https://www.nvidia.com/en-us/drivers/unix/). -#### Configuring Nvidia GPUs in Docker +### Configuring Nvidia GPUs in Docker Additional configuration is needed for the Docker container to be able to access the NVIDIA GPU. The supported method for this is to install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) and specify the GPU to Docker. How you do this depends on how Docker is being run: -##### Docker Compose - Nvidia GPU +#### Docker Compose - Nvidia GPU ```yaml services: @@ -165,7 +167,7 @@ services: capabilities: [gpu] ``` -##### Docker Run CLI - Nvidia GPU +#### Docker Run CLI - Nvidia GPU ```bash docker run -d \ @@ -175,7 +177,7 @@ docker run -d \ ghcr.io/blakeblackshear/frigate:stable ``` -#### Setup Decoder +### Setup Decoder The decoder you need to pass in the `hwaccel_args` will depend on the input video. @@ -242,3 +244,5 @@ processes: If you do not see these processes, check the `docker logs` for the container and look for decoding errors. These instructions were originally based on the [Jellyfin documentation](https://jellyfin.org/docs/general/administration/hardware-acceleration.html#nvidia-hardware-acceleration-on-docker-linux). + +# Community Supported diff --git a/docs/docs/configuration/object_detectors.md b/docs/docs/configuration/object_detectors.md index db9647420..93c439b64 100644 --- a/docs/docs/configuration/object_detectors.md +++ b/docs/docs/configuration/object_detectors.md @@ -3,6 +3,8 @@ id: object_detectors title: Object Detectors --- +# Officially Supported Detectors + Frigate provides the following builtin detector types: `cpu`, `edgetpu`, `openvino`, and `tensorrt`. By default, Frigate will use a single CPU detector. Other detectors may require additional configuration as described below. When using multiple detectors they will run in dedicated processes, but pull from a common queue of detection requests from across all cameras. ## CPU Detector (not recommended) @@ -278,3 +280,6 @@ detectors: Replace `` and `` with the IP address and port of your CodeProject.AI server. To verify that the integration is working correctly, start Frigate and observe the logs for any error messages related to CodeProject.AI. Additionally, you can check the Frigate web interface to see if the objects detected by CodeProject.AI are being displayed and tracked properly. + + +# Community Supported Detectors diff --git a/docs/docs/development/contributing-boards.md b/docs/docs/development/contributing-boards.md new file mode 100644 index 000000000..49a65722d --- /dev/null +++ b/docs/docs/development/contributing-boards.md @@ -0,0 +1,94 @@ +--- +id: contributing-boards +title: Community Supported Boards +--- + +## About Community Supported Boards + +There are many SBCs (small board computers) that have a passionate community behind them, Jetson Nano for example. These SBCs often have dedicated hardware that can greatly accelerate Frigate's AI and video workloads, but this hardware requires very specific frameworks for interfacing with it. + +This means it would be very difficult for Frigate's maintainers to support these different boards especially given the relatively low userbase. + +The community support boards framework allows a user in the community to be the codeowner to add support for an SBC or other detector by providing the code, maintenance, and user support. + +## Getting Started + +1. Follow the steps from [the main contributing docs](/development/contributing.md). +2. Create a new build type under `docker/` +3. Get build working as expected, all board-specific changes should be done inside of the board specific docker file. + +## Required Structure + +Each board will have different build requirements, run on different architectures, etc. however there are set of files that all boards will need. + +### Bake File .hcl + +The `board.hcl` file is what allows the community boards build to be built using the main build as a cache. This enables a clean base and quicker build times. For more information on the format and options available in the Bake file, [see the official Buildx Bake docs](https://docs.docker.com/build/bake/reference/) + +### Board Make File + +The `board.mk` file is what allows automated and configurable Make targets to be included in the main Make file. Below is the general format for this file: + +```Makefile +BOARDS += board # Replace `board` with the board suffix ex: rpi + +local-rpi: version + docker buildx bake --load --file=docker/board/board.hcl --set board.tags=frigate:latest-board bake-target # Replace `board` with the board suffix ex: rpi. Bake target is the target in the board.hcl file ex: board + +build-rpi: version + docker buildx bake --file=docker/board/board.hcl --set board.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-board bake-target # Replace `board` with the board suffix ex: rpi. Bake target is the target in the board.hcl file ex: board + +push-rpi: build-rpi + docker buildx bake --push --file=docker/board/board.hcl --set board.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-board bake-target # Replace `board` with the board suffix ex: rpi. Bake target is the target in the board.hcl file ex: board +``` + +### Dockerfile + +The `Dockerfile` is what orchestrates the build, this will vary greatly depending on the board but some parts are required for things to work. Below are the required parts of the Dockerfile: + +```Dockerfile +# syntax=docker/dockerfile:1.4 + +# https://askubuntu.com/questions/972516/debian-frontend-environment-variable +ARG DEBIAN_FRONTEND=noninteractive + +# All board-specific work should be done with `deps` as the base +FROM deps AS board-deps + +# do stuff specific +# to the board + +# set workdir +WORKDIR /opt/frigate/ + +# copies base files from the main frigate build +COPY --from=rootfs / / +``` + +## Other Required Changes + +### CI/CD + +The images for each board will be built for each Frigate release, this is done in the `.github/workflows/ci.yml` file. The board build workflow will need to be added here. + +```yml + - name: Build and push board build + uses: docker/bake-action@v3 + with: + push: true + targets: board # this is the target in the board.hcl file + files: docker/board/board.hcl # this should be updated with the actual board type + # the tags should be updated with the actual board types as well + # the community board builds should never push to cache, but it can pull from cache + set: | + board.tags=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-board + *.cache-from=type=gha +``` + +### Code Owner File + +The `CODEOWNERS` file should be updated to include the `docker/board` along with `@user` for each user that is a code owner of this board + +# Docs + +At a minimum the `installation`, `object_detectors`, `hardware_acceleration`, and `ffmpeg-presets` docs should be updated (if applicable) to reflect the configuration of this community board. diff --git a/docs/docs/development/contributing.md b/docs/docs/development/contributing.md index 4ea6b6255..3045546c6 100644 --- a/docs/docs/development/contributing.md +++ b/docs/docs/development/contributing.md @@ -1,6 +1,6 @@ --- id: contributing -title: Contributing +title: Contributing To The Main Code Base --- ## Getting the source diff --git a/docs/docs/frigate/installation.md b/docs/docs/frigate/installation.md index 1397f8741..b8f33da77 100644 --- a/docs/docs/frigate/installation.md +++ b/docs/docs/frigate/installation.md @@ -83,6 +83,18 @@ Additionally, the USB Coral draws a considerable amount of power. If using any o Running in Docker with compose is the recommended install method: +:::note + +The following officially supported builds are available: + +`ghcr.io/blakeblackshear/frigate:stable` - Standard Frigate build for amd64 & RPi Optimized Frigate build for arm64 +`ghcr.io/blakeblackshear/frigate:stable-standard-arm64` - Standard Frigate build for arm64 +`ghcr.io/blakeblackshear/frigate:stable-tensorrt` - Frigate build specific for amd64 devices running an nvidia GPU + +The following community supported builds are available: + +::: + ```yaml version: "3.9" services: diff --git a/docs/sidebars.js b/docs/sidebars.js index 35ce2bee3..bbb9597af 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -45,6 +45,7 @@ module.exports = { ], Development: [ "development/contributing", + "development/contributing-boards" ], }, };