From b594f198a95f85b1bf68c7df95179f05e6eef9c2 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 11 Feb 2025 09:08:13 -0700 Subject: [PATCH] Consolidate HailoRT into the main Docker Image (#16487) * Simplify main build to include hailo * Update docs * Remove hailo docker build --- .github/workflows/ci.yml | 27 -------------- docker/hailo8l/Dockerfile | 42 ---------------------- docker/hailo8l/h8l.hcl | 34 ------------------ docker/hailo8l/h8l.mk | 15 -------- docker/hailo8l/install_hailort.sh | 19 ---------- docker/hailo8l/requirements-wheels-h8l.txt | 12 ------- docker/main/Dockerfile | 4 +++ docker/main/install_hailort.sh | 14 ++++++++ docker/main/requirements-wheels.txt | 13 +++++++ docs/docs/frigate/installation.md | 2 +- 10 files changed, 32 insertions(+), 150 deletions(-) delete mode 100644 docker/hailo8l/Dockerfile delete mode 100644 docker/hailo8l/h8l.hcl delete mode 100644 docker/hailo8l/h8l.mk delete mode 100755 docker/hailo8l/install_hailort.sh delete mode 100644 docker/hailo8l/requirements-wheels-h8l.txt create mode 100755 docker/main/install_hailort.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf5763c00..2046ed100 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,33 +202,6 @@ jobs: set: | rk.tags=${{ steps.setup.outputs.image-name }}-rk *.cache-from=type=gha - combined_extra_builds: - runs-on: ubuntu-22.04 - name: Combined Extra Builds - needs: - - amd64_build - - arm64_build - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up QEMU and Buildx - id: setup - uses: ./.github/actions/setup - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Hailo-8l build - uses: docker/bake-action@v6 - with: - source: . - push: true - targets: h8l - files: docker/hailo8l/h8l.hcl - set: | - h8l.tags=${{ steps.setup.outputs.image-name }}-h8l - *.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l - *.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l,mode=max # The majority of users running arm64 are rpi users, so the rpi # build should be the primary arm64 image assemble_default_build: diff --git a/docker/hailo8l/Dockerfile b/docker/hailo8l/Dockerfile deleted file mode 100644 index 33b5b08f0..000000000 --- a/docker/hailo8l/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# syntax=docker/dockerfile:1.6 - -ARG DEBIAN_FRONTEND=noninteractive - -# Build Python wheels -FROM wheels AS h8l-wheels - -RUN python3 -m pip config set global.break-system-packages true -COPY docker/main/requirements-wheels.txt /requirements-wheels.txt -COPY docker/hailo8l/requirements-wheels-h8l.txt /requirements-wheels-h8l.txt - -RUN sed -i "/https:\/\//d" /requirements-wheels.txt - -# Create a directory to store the built wheels -RUN mkdir /h8l-wheels - -# Build the wheels -RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requirements-wheels-h8l.txt - -FROM wget AS hailort -ARG TARGETARCH -RUN --mount=type=bind,source=docker/hailo8l/install_hailort.sh,target=/deps/install_hailort.sh \ - /deps/install_hailort.sh - -# Use deps as the base image -FROM deps AS h8l-frigate - -# Copy the wheels from the wheels stage -COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels -COPY --from=hailort /hailo-wheels /deps/hailo-wheels -COPY --from=hailort /rootfs/ / - -# Install the wheels -RUN python3 -m pip config set global.break-system-packages true -RUN pip3 install -U /deps/h8l-wheels/*.whl -RUN pip3 install -U /deps/hailo-wheels/*.whl - -# Copy base files from the rootfs stage -COPY --from=rootfs / / - -# Set workdir -WORKDIR /opt/frigate/ diff --git a/docker/hailo8l/h8l.hcl b/docker/hailo8l/h8l.hcl deleted file mode 100644 index 91f6d13c6..000000000 --- a/docker/hailo8l/h8l.hcl +++ /dev/null @@ -1,34 +0,0 @@ -target wget { - dockerfile = "docker/main/Dockerfile" - platforms = ["linux/arm64","linux/amd64"] - target = "wget" -} - -target wheels { - dockerfile = "docker/main/Dockerfile" - platforms = ["linux/arm64","linux/amd64"] - target = "wheels" -} - -target deps { - dockerfile = "docker/main/Dockerfile" - platforms = ["linux/arm64","linux/amd64"] - target = "deps" -} - -target rootfs { - dockerfile = "docker/main/Dockerfile" - platforms = ["linux/arm64","linux/amd64"] - target = "rootfs" -} - -target h8l { - dockerfile = "docker/hailo8l/Dockerfile" - contexts = { - wget = "target:wget" - wheels = "target:wheels" - deps = "target:deps" - rootfs = "target:rootfs" - } - platforms = ["linux/arm64","linux/amd64"] -} diff --git a/docker/hailo8l/h8l.mk b/docker/hailo8l/h8l.mk deleted file mode 100644 index 318771802..000000000 --- a/docker/hailo8l/h8l.mk +++ /dev/null @@ -1,15 +0,0 @@ -BOARDS += h8l - -local-h8l: version - docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ - --set h8l.tags=frigate:latest-h8l \ - --load - -build-h8l: version - docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ - --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l - -push-h8l: build-h8l - docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ - --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l \ - --push \ No newline at end of file diff --git a/docker/hailo8l/install_hailort.sh b/docker/hailo8l/install_hailort.sh deleted file mode 100755 index c0198b34c..000000000 --- a/docker/hailo8l/install_hailort.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -hailo_version="4.20.0" - -if [[ "${TARGETARCH}" == "amd64" ]]; then - arch="x86_64" -elif [[ "${TARGETARCH}" == "arm64" ]]; then - arch="aarch64" -fi - -wget -qO- "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${TARGETARCH}.tar.gz" | - tar -C / -xzf - - -mkdir -p /hailo-wheels - -wget -P /hailo-wheels/ "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${hailo_version}-cp311-cp311-linux_${arch}.whl" - diff --git a/docker/hailo8l/requirements-wheels-h8l.txt b/docker/hailo8l/requirements-wheels-h8l.txt deleted file mode 100644 index e125f9e8b..000000000 --- a/docker/hailo8l/requirements-wheels-h8l.txt +++ /dev/null @@ -1,12 +0,0 @@ -appdirs==1.4.* -argcomplete==2.0.* -contextlib2==0.6.* -distlib==0.3.* -filelock==3.8.* -future==0.18.* -importlib-metadata==5.1.* -importlib-resources==5.1.* -netaddr==0.8.* -netifaces==0.10.* -verboselogs==1.7.* -virtualenv==20.17.* diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index e6dee8380..4c3416789 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -170,6 +170,9 @@ RUN /build_pysqlite3.sh COPY docker/main/requirements-wheels.txt /requirements-wheels.txt RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt +# Install HailoRT & Wheels +RUN --mount=type=bind,source=docker/main/install_hailort.sh,target=/deps/install_hailort.sh \ + /deps/install_hailort.sh # Collect deps in a single layer FROM scratch AS deps-rootfs @@ -180,6 +183,7 @@ COPY --from=libusb-build /usr/local/lib /usr/local/lib COPY --from=tempio /rootfs/ / COPY --from=s6-overlay /rootfs/ / COPY --from=models /rootfs/ / +COPY --from=wheels /rootfs/ / COPY docker/main/rootfs/ / diff --git a/docker/main/install_hailort.sh b/docker/main/install_hailort.sh new file mode 100755 index 000000000..e050bd591 --- /dev/null +++ b/docker/main/install_hailort.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euxo pipefail + +hailo_version="4.20.0" + +if [[ "${TARGETARCH}" == "amd64" ]]; then + arch="x86_64" +elif [[ "${TARGETARCH}" == "arm64" ]]; then + arch="aarch64" +fi + +wget -qO- "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${TARGETARCH}.tar.gz" | tar -C / -xzf - +wget -P /wheels/ "https://github.com/frigate-nvr/hailort/releases/download/v${hailo_version}/hailort-${hailo_version}-cp311-cp311-linux_${arch}.whl" diff --git a/docker/main/requirements-wheels.txt b/docker/main/requirements-wheels.txt index 40a2f1d8b..ab91c94a7 100644 --- a/docker/main/requirements-wheels.txt +++ b/docker/main/requirements-wheels.txt @@ -54,3 +54,16 @@ pywebpush == 2.0.* pyclipper == 1.3.* shapely == 2.0.* prometheus-client == 0.21.* +# HailoRT Wheels +appdirs==1.4.* +argcomplete==2.0.* +contextlib2==0.6.* +distlib==0.3.* +filelock==3.8.* +future==0.18.* +importlib-metadata==5.1.* +importlib-resources==5.1.* +netaddr==0.8.* +netifaces==0.10.* +verboselogs==1.7.* +virtualenv==20.17.* diff --git a/docs/docs/frigate/installation.md b/docs/docs/frigate/installation.md index 2c139d2bd..e14559697 100644 --- a/docs/docs/frigate/installation.md +++ b/docs/docs/frigate/installation.md @@ -117,7 +117,7 @@ For other installations, follow these steps for installation: #### Setup -To set up Frigate, follow the default installation instructions, but use a Docker image with the `-h8l` suffix, for example: `ghcr.io/blakeblackshear/frigate:stable-h8l` +To set up Frigate, follow the default installation instructions, for example: `ghcr.io/blakeblackshear/frigate:stable` Next, grant Docker permissions to access your hardware by adding the following lines to your `docker-compose.yml` file: