Skip to content

Commit

Permalink
Add rae images
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilpastukhov committed Aug 2, 2023
1 parent 41a5b5f commit 98fac38
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 8 deletions.
69 changes: 69 additions & 0 deletions docker_images/rae/builtin_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# syntax=docker/dockerfile:experimental
FROM ubuntu:22.04 as origin

ENV PYTHONPATH=/lib \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

ARG DEBIAN_FRONTEND=noninteractive
ARG OPENCV_VERSION=4.7.0

FROM origin as base

# Install Python 3
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends python3 python3-pip && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

FROM base as build

RUN apt-get update && \
apt-get install -q -y --no-install-recommends git ca-certificates wget bzip2 build-essential cmake python3-dev && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

RUN wget https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2 -O libusb.tar.bz2 && \
git clone --depth=1 --branch "rvc3_develop" --recurse-submodules https://github.com/luxonis/depthai-python.git

RUN wget -O /tmp/linux_netlink.c https://raw.githubusercontent.com/luxonis/robothub-images/main/docker_images/linux_netlink.c
RUN tar xf libusb.tar.bz2 \
&& cd libusb-* \
&& rm ./libusb/os/linux_netlink.c \
&& cp /tmp/linux_netlink.c ./libusb/os/linux_netlink.c \
&& ./configure --disable-udev \
&& make -j$(nproc) \
&& cp ./libusb/.libs/libusb-1.0.so.0.3.0 /tmp/libusb-1.0.so

RUN pip3 install --no-cache-dir --only-binary=:all: numpy
RUN cd depthai-python \
&& cmake -H. -B build -D CMAKE_BUILD_TYPE=Release -D DEPTHAI_ENABLE_BACKWARD=OFF \
&& cmake --build build --parallel $(nproc)

# Package dependencies
RUN mkdir -p /opt/depthai \
&& for dep in $(ldd /depthai-python/build/depthai*.so 2>/dev/null | awk 'BEGIN{ORS=" "}$1 ~/^\//{print $1}$3~/^\//{print $3}' | sed 's/,$/\n/'); do cp "$dep" /opt/depthai; done \
&& mv /depthai-python/build/depthai*.so /opt/depthai

# Clear Python compiled artifacts
RUN find /usr -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
\) -exec rm -rf '{}' +

RUN apt-get purge -y --auto-remove \
build-essential \
cmake \
git \
wget \
bzip2 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

FROM base

# Squash the image to save on space
COPY --from=build /opt/depthai /lib
COPY --from=build /tmp/libusb-1.0.so /lib/libusb-1.0.so
COPY --from=build /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
71 changes: 71 additions & 0 deletions docker_images/rae/provisioning_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# syntax=docker/dockerfile:experimental
FROM ubuntu:22.04 as origin

ENV PYTHONPATH=/lib \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

ARG DEBIAN_FRONTEND=noninteractive
ARG OPENCV_VERSION=4.7.0

FROM origin as base

# Install Python 3
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends python3 python3-pip && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

FROM base as build

RUN apt-get update && \
apt-get install -q -y --no-install-recommends git ca-certificates wget bzip2 build-essential cmake python3-dev && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

RUN wget https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2 -O libusb.tar.bz2 && \
git clone --depth=1 --branch "rvc3_develop" --recurse-submodules https://github.com/luxonis/depthai-python.git

RUN wget -O /tmp/linux_netlink.c https://raw.githubusercontent.com/luxonis/robothub-images/main/docker_images/linux_netlink.c
RUN tar xf libusb.tar.bz2 \
&& cd libusb-* \
&& rm ./libusb/os/linux_netlink.c \
&& cp /tmp/linux_netlink.c ./libusb/os/linux_netlink.c \
&& ./configure --disable-udev \
&& make -j$(nproc) \
&& cp ./libusb/.libs/libusb-1.0.so.0.3.0 /tmp/libusb-1.0.so

RUN pip3 install --no-cache-dir --only-binary=:all: numpy
RUN cd depthai-python \
&& cmake -H. -B build -D CMAKE_BUILD_TYPE=Release -D DEPTHAI_ENABLE_BACKWARD=OFF \
&& cmake --build build --parallel $(nproc)

# Package dependencies
RUN mkdir -p /opt/depthai \
&& for dep in $(ldd /depthai-python/build/depthai*.so 2>/dev/null | awk 'BEGIN{ORS=" "}$1 ~/^\//{print $1}$3~/^\//{print $3}' | sed 's/,$/\n/'); do cp "$dep" /opt/depthai; done \
&& mv /depthai-python/build/depthai*.so /opt/depthai

# Clear Python compiled artifacts
RUN find /usr -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
\) -exec rm -rf '{}' +

RUN pip3 install --no-cache-dir --only-binary=:all: opencv-contrib-python-headless

RUN apt-get purge -y --auto-remove \
build-essential \
cmake \
git \
wget \
bzip2 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

FROM base

# Squash the image to save on space
COPY --from=build /opt/depthai /lib
COPY --from=build /tmp/libusb-1.0.so /lib/libusb-1.0.so
COPY --from=build /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
50 changes: 42 additions & 8 deletions scripts/build-rvc3-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ TAG_SUFFIX=""

DEPTHAI_BRANCH="rvc3_develop"

if [[ -n "${EXTERNAL_TRIGGER_REF}" ]]; then
DEPTHAI_BRANCH="${EXTERNAL_TRIGGER_REF##*/}"
elif [[ -z "${DEPTHAI_BRANCH}" ]]; then
DEPTHAI_BRANCH="main"
else
TAG_SUFFIX="${TAG_SUFFIX}-custom"
fi

if [[ "$GITHUB_REF_NAME" != "main" ]]; then
TAG_SUFFIX="${TAG_SUFFIX}-dev"
fi
Expand All @@ -33,6 +25,8 @@ BASE_PACKAGE="ghcr.io/luxonis/robothub-app-v2"
BASE_TAG="${BASE_PACKAGE}:${IMAGE_VERSION}"
BASE_RVC3_TAG="${BASE_TAG}-rvc3${TAG_SUFFIX}"
BASE_ROS2HUMBLE_RVC3_TAG="${BASE_TAG}-ros2humble-rvc3${TAG_SUFFIX}"
RAE_PROV_TAG="${BASE_TAG}-rae-provisioning${TAG_SUFFIX}"
RAE_BUILTIN_TAG="${BASE_TAG}-rae-builtin${TAG_SUFFIX}"

echo "================================"
echo "Building images..."
Expand Down Expand Up @@ -83,6 +77,46 @@ DOCKER_BUILDKIT=1 docker buildx \
--file ./docker_images/ros/humble/rvc3/Dockerfile \
./

echo "================================"
echo "Building RAE..."
echo "=> ${RAE_PROV_TAG}"
DOCKER_BUILDKIT=1 docker buildx \
build \
--builder remotebuilder \
--platform linux/amd64,linux/arm64 \
--label "com.luxonis.rh.depthai=${DEPTHAI_VERSION}" \
--label "com.luxonis.rh.depthai.branch=${DEPTHAI_BRANCH}" \
--label "com.luxonis.rh.base=ubuntu22.04" \
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \
--label "org.opencontainers.image.vendor=Luxonis" \
--label "org.opencontainers.image.title=RobotHub RAE provisioning app image" \
--label "org.opencontainers.image.description=Based on: Ubuntu\nDepthAI branch: ${DEPTHAI_BRANCH}\nDepthAI version: ${DEPTHAI_VERSION}" \
-t "${RAE_PROV_TAG}" \
--push \
--provenance=false \
--file ./docker_images/rae/provisioning_app/Dockerfile \
./

echo "=> ${RAE_PROV_TAG}"
echo "================================"

DOCKER_BUILDKIT=1 docker buildx \
build \
--builder remotebuilder \
--platform linux/amd64,linux/arm64 \
--label "com.luxonis.rh.depthai=${DEPTHAI_VERSION}" \
--label "com.luxonis.rh.depthai.branch=${DEPTHAI_BRANCH}" \
--label "com.luxonis.rh.base=ubuntu22.04" \
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \
--label "org.opencontainers.image.vendor=Luxonis" \
--label "org.opencontainers.image.title=RobotHub RAE builtin app image" \
--label "org.opencontainers.image.description=Based on: Ubuntu\nDepthAI branch: ${DEPTHAI_BRANCH}\nDepthAI version: ${DEPTHAI_VERSION}" \
-t "${RAE_PROV_TAG}" \
--push \
--provenance=false \
--file ./docker_images/rae/builtin_app/Dockerfile \
./

echo "================================"
echo "All done!"
echo "================================"

0 comments on commit 98fac38

Please sign in to comment.