Skip to content

Commit

Permalink
Rework structure and images (#22)
Browse files Browse the repository at this point in the history
* Rework dockerfiles and build process (#20)

* Improve files structure

* Build libusb in external/libusb folder

* Remove dead code in dockerfiles

* Fix libusb file naming

* Fix ros2humble dockerfiles

* Use prebuilt libusb in dockerfiles

* Use wheels instead of building depthai

* Remove excessive apt-get clean

* Remove excessive apt-get -y flag

* Merge origin and base stages

* Remove excessive apt-get purge

- It was the last command in build stage, but final stage is not based
  on build stage

* Remove update-alternatives for python

* Remove experimental syntax support

* Always ensure python3 is installed

* Always upgrade pip, setuptools and wheel

* Add distinctipy to regular images

* Fix comment

* Remove unused OPENCV_VERSION arg

* Always set DEBIAN_FRONTEND=noninteractive

* Use upper case for dockerfile instructions

* Add base dockerfile with ROBOTICS_VISION_CORE arg

* Add BASE_IMAGE arg

* Use VARIANT arg to install python packages

* Remove hardcoded dockerfiles

- Use base dockerfile instead

* Remove depthai branch from workflow dispatch inputs

* Remove unused paths filter in push trigger

* Format publish-base-images.yml workflow file

* Remove repository dispatch trigger

* Fix style in scripts

* Add DEPTHAI_VERSION arg

* Move precompiled libusb to docker build context

* Remove unused dependencies installation from custom dockerfiles

* Format setup-remote-builder.sh script

* Rework build scripts

* Add DEPTHAI_SDK_VERSION arg

* Add ROBOTHUB_OAK_VERSION arg

* Update README.md

* Fix hardcoded base image in build script

* Run scripts with bash instead of sh

* Provide script to install specific version of depthai

* Remove unused pyproject.toml

* Don't upgrade pip, setuptools and wheels

- Upgrade doesn't uninstall previous versions installed by apt-get
- Image size is reduced by ~38MB

* Build and publish libusb using GitHub workflow

* Temporarily remove push trigger for buliding images

* Fix yaml syntax

* Use sudo apt-get to install dependencies

* Set fail-fast to false in libusb workflow

* Add aws cli installing to libusb workflow

* Fix aws cli installation

* Download precompiled libusb from rh-public in dockerfiles

* Revert "Temporarily remove push trigger for buliding images"

This reverts commit bb99232.

* Improve installation scripts

* Add core image with no preinstalled packages

* Use buildjet runners to build docker images (#21)

* Remove build workflow that uses aws

* Remove --builder and --platform flags

* Add architecture suffix to image tags

* Remove image version derivation from scripts

* Add make_manifests.sh script

* Add new image build workflow that uses buildjet

* Add checkout action to make-manifests job

* Add name to all jobs/steps

* Remove unused NODE_AUTH_TOKEN env variable

* Use buildx imagetools to make manifests

- Fix issue with unknown manifest

* Remove on push to main trigger

* Publish to robothub-app-v2 on release, otherwise to robothub-app-v2-dev

* Remove on push to develop trigger

* Change depthai-sdk version to 1.12.1

* Use robothub 2.2.0 (renamed robothub-oak)

---------

Co-authored-by: OpeningNew <[email protected]>
Co-authored-by: Nikolay Tsoy <[email protected]>
  • Loading branch information
3 people authored Sep 28, 2023
1 parent 4f07e03 commit a60589e
Show file tree
Hide file tree
Showing 33 changed files with 541 additions and 1,100 deletions.
84 changes: 0 additions & 84 deletions .github/workflows/publish-base-images.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and publish images

on:
workflow_dispatch:
release:
types: [published]

env:
IMAGE_REF_NAME: ${{ github.event_name == 'release' && 'robothub-app-v2' || 'robothub-app-v2-dev' }}

jobs:
generate-version:
name: Generate image version
runs-on: buildjet-2vcpu-ubuntu-2204
outputs:
version: ${{ steps.generate-version.outputs.version }}
steps:
- name: Generate image version
id: generate-version
run: echo "version=$(date +%Y.%j.%H%M)" >> "$GITHUB_OUTPUT"
build:
name: Build & push images
permissions:
packages: write
contents: read
needs: generate-version
strategy:
fail-fast: false
matrix:
runner:
- { runs-on: buildjet-4vcpu-ubuntu-2204, arch: amd64 }
- { runs-on: buildjet-4vcpu-ubuntu-2204-arm, arch: arm64 }
env:
IMAGE_VERSION: ${{ needs.generate-version.outputs.version }}
ARCH: ${{ matrix.runner.arch }}
runs-on: ${{ matrix.runner.runs-on }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push images
run: ./scripts/build-images.sh
make-manifests:
name: Make multi-arch manifests
permissions:
packages: write
contents: read
needs: [generate-version, build]
env:
IMAGE_VERSION: ${{ needs.generate-version.outputs.version }}
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Make multi-arch manifests
run: ./scripts/make-manifests.sh
48 changes: 48 additions & 0 deletions .github/workflows/publish-patched-libusb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and publish patched libusb

on:
workflow_dispatch:

jobs:
build-libusb:
name: Build & publish patched libusb
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix:
runner:
- {runs-on: buildjet-2vcpu-ubuntu-2204, arch: x86_64}
- {runs-on: buildjet-2vcpu-ubuntu-2204-arm, arch: aarch64}
runs-on: ${{ matrix.runner.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq --no-install-recommends ca-certificates wget bzip2 build-essential
- name: Build libusb
working-directory: external/libusb/
run: |
wget https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2
tar xf libusb-1.0.26.tar.bz2
cp linux_netlink.c libusb-1.0.26/libusb/os/linux_netlink.c
cd libusb-1.0.26
./configure --disable-udev
make -j$(nproc)
- name: Install aws cli
env:
ARCHITECTURE: ${{ matrix.runner.arch }}
run: |
wget -O "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-$ARCHITECTURE.zip"
unzip awscliv2.zip
sudo ./aws/install --update
- name: Upload to bucket
working-directory: external/libusb/
env:
ARCHITECTURE: ${{ matrix.runner.arch }}
AWS_ACCESS_KEY_ID: ${{ secrets.RH_PUBLIC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RH_PUBLIC_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL: ${{ secrets.RH_PUBLIC_ENDPOINT }}
run: aws s3 cp libusb-1.0.26/libusb/.libs/libusb-1.0.so.0.3.0 s3://rh-public/libusb/1.0.26/libusb-$ARCHITECTURE.so
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
# RobotHub-Images Repository
# RobotHub Images Repository

This repository contains the Dockerfiles used to build the images for RobotHub apps.

## Available Images
> **Note**: All images are available at [GitHub Packages](https://github.com/luxonis/robothub-images/pkgs/container/robothub-app-v2).
- minimal: Debian-based image with minimal dependencies for running RobotHub apps
- regular: Ubuntu-based image for running RobotHub apps (recommended)
- ros2humble: Ubuntu-based image for running RobotHub apps with ROS2 Humble installed

> [!NOTE]
> All images are available at [GitHub Packages](https://github.com/luxonis/robothub-images/pkgs/container/robothub-app-v2).
### Robotics Vision Core

- `RVC2` ([OAK Series 2](https://docs.luxonis.com/projects/hardware/en/latest/pages/articles/oak-s2/))
- `RVC3` ([OAK Series 3](https://docs.luxonis.com/projects/hardware/en/latest/pages/articles/oak-s3/))

### Variant

- `minimal`: Ubuntu-based image with minimal dependencies for running RobotHub apps
- `regular`: Ubuntu-based image for running RobotHub apps (recommended)

### ROS2

- `ros2humble`: Ubuntu-based image for running RobotHub apps with ROS2 Humble installed

## Making first app

Please visit [RobotHub documentation page](https://docs-beta.luxonis.com/robothub/get-started) for more information about how to make your
Please visit [RobotHub documentation page](https://docs-beta.luxonis.com/develop/quick-start) for more information about how to make your
first app.

## License

This project is licensed under the terms of the MIT license.

If you have any questions about Perception Apps or RobotHub, please visit our [Documentation](https://hub-docs.luxonis.com/docs/perception-apps/overview) or ask us directly on the [forums](https://discuss.luxonis.com).

If you have any questions about Perception Apps or RobotHub, please visit our [Documentation](https://docs-beta.luxonis.com/) or ask us directly on the [forums](https://discuss.luxonis.com).
22 changes: 22 additions & 0 deletions context/download-patched-libusb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

TARGETARCH_LINUX=""
if [[ $# -eq 0 ]]; then
TARGETARCH_LINUX=$(uname -m)
elif [[ $# -eq 1 ]]; then
TARGETARCH=$1
if [[ "${TARGETARCH}" == "amd64" ]]; then
TARGETARCH_LINUX="x86_64"
elif [[ "${TARGETARCH}" == "arm64" ]]; then
TARGETARCH_LINUX="aarch64"
else
echo "Unknown TARGETARCH: ${TARGETARCH}"
exit 1
fi
else
echo "Usage: $0 [target-arch]"
echo "target-arch: amd64, arm64"
exit 1
fi

wget -O /lib/libusb-1.0.so "https://rh-public.luxonis.com/libusb/1.0.26/libusb-${TARGETARCH_LINUX}.so"
14 changes: 14 additions & 0 deletions context/install-depthai-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [[ $# -ne 1 ]]; then
echo "Usage: $0 <depthai-version>"
exit 1
fi

DEPTHAI_VERSION=$1

echo "Installing depthai version: ${DEPTHAI_VERSION}"
pip3 install --no-deps --no-cache-dir --extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/ depthai==${DEPTHAI_VERSION}

echo "Patching depthai installation..."
find /usr/local/lib/python3.10/dist-packages/depthai.libs -type f -name "libusb*.so" -print -exec cp /lib/libusb-1.0.so {} \;
22 changes: 22 additions & 0 deletions context/install-luxonis-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [[ $# -ne 3 ]]; then
echo "Usage: $0 [robotics-vision-core] [depthai-sdk-version] [robothub-oak-version]"
echo "robotics-vision-core: rvc2, rvc3"
exit 1
fi

ROBOTICS_VISION_CORE=$1
DEPTHAI_SDK_VERSION=$2
ROBOTHUB_VERSION=$3

if [[ "$ROBOTICS_VISION_CORE" == "rvc2" ]]; then
pip3 install --no-deps --no-cache-dir depthai-sdk==${DEPTHAI_SDK_VERSION}
pip3 install --no-deps --no-cache-dir robothub==${ROBOTHUB_VERSION}
elif [[ "$ROBOTICS_VISION_CORE" == "rvc3" ]]; then
pip3 install --no-deps --no-cache-dir "git+https://github.com/luxonis/depthai.git@${DEPTHAI_SDK_VERSION}#subdirectory=depthai_sdk"
pip3 install --no-deps --no-cache-dir robothub==${ROBOTHUB_VERSION}
else
echo "Unknown ROBOTICS_VISION_CORE: ${ROBOTICS_VISION_CORE}"
exit 1
fi
7 changes: 7 additions & 0 deletions context/requirements-minimal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distinctipy
marshmallow
numpy
opencv-contrib-python-headless
requests
sentry-sdk
xmltodict
9 changes: 9 additions & 0 deletions context/requirements-regular.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
av
blobconverter
distinctipy
marshmallow
numpy
opencv-contrib-python-headless
requests
sentry-sdk
xmltodict
Loading

0 comments on commit a60589e

Please sign in to comment.