From 8f4b31cbeb554a489ddaf6b482377a461d2b211e Mon Sep 17 00:00:00 2001 From: Tomas Baca Date: Wed, 22 Jan 2025 15:02:06 +0100 Subject: [PATCH] updated build scripts --- docker/hailo_ai/build_arm64.sh | 8 ---- docker/hailo_ai/build_image.sh | 48 +++++++++++++++++++ .../shared_data/camera_tests/build_image.sh | 32 +++++++++---- docker/shared_data/gnss/build_image.sh | 32 +++++++++---- docker/shared_data/vio/build_image.sh | 32 +++++++++---- 5 files changed, 117 insertions(+), 35 deletions(-) delete mode 100755 docker/hailo_ai/build_arm64.sh create mode 100755 docker/hailo_ai/build_image.sh diff --git a/docker/hailo_ai/build_arm64.sh b/docker/hailo_ai/build_arm64.sh deleted file mode 100755 index b88b064..0000000 --- a/docker/hailo_ai/build_arm64.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -LOCAL_TAG=mrs_uav_system:1.5.0_hailo_ai -REGISTRY=ctumrs - -docker buildx use default - -docker build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=linux/arm64 diff --git a/docker/hailo_ai/build_image.sh b/docker/hailo_ai/build_image.sh new file mode 100755 index 0000000..4cfbe27 --- /dev/null +++ b/docker/hailo_ai/build_image.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# get the path to this script +MY_PATH=`dirname "$0"` +MY_PATH=`( cd "$MY_PATH" && pwd )` + +cd ${MY_PATH} + +## -------------------------------------------------------------- +## | setup | +## -------------------------------------------------------------- + +LOCAL_TAG=mrs_uav_system:1.5.0_hailo_ai +REGISTRY=ctumrs + +# single-platform image can be stored locally +# ARCH=linux/amd64 +ARCH=linux/arm64 +OUTPUT="--output type=docker" + +# multi-platform image can not be stored locally, needs to be pushed +# ARCH=linux/arm64,linux/amd64 +# OUTPUT="--push" + +## -------------------------------------------------------------- +## | build | +## -------------------------------------------------------------- + +# multiplatform builder +BUILDER=container-builder + +# get info about an existing builder +container_builder_info=$(docker buildx inspect ${BUILDER}) + +if [[ "$?" == "0" ]]; then + # activate the builder if it exists + docker buildx use ${BUILDER} +else + # create the builder if it does not exist + docker buildx create --name ${BUILDER} --driver docker-container --bootstrap --use +fi + +# build the docker image using the builder and export the results to the local docker registry +docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=${ARCH} ${OUTPUT} + +echo "" +echo "$0: shared data were packed into '$LOCAL_TAG'" +echo "" diff --git a/docker/shared_data/camera_tests/build_image.sh b/docker/shared_data/camera_tests/build_image.sh index 5a114d0..f780f61 100755 --- a/docker/shared_data/camera_tests/build_image.sh +++ b/docker/shared_data/camera_tests/build_image.sh @@ -1,10 +1,5 @@ #!/bin/bash -set -e - -trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG -trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR - # get the path to this script MY_PATH=`dirname "$0"` MY_PATH=`( cd "$MY_PATH" && pwd )` @@ -18,16 +13,35 @@ cd ${MY_PATH} LOCAL_TAG=robofly:shared_data_camera_tests REGISTRY=fly4future -ARCH=arm64 # robofly -# ARCH=amd64 +# single-platform image can be stored locally +# ARCH=linux/amd64 +ARCH=linux/arm64 +OUTPUT="--output type=docker" + +# multi-platform image can not be stored locally, needs to be pushed +# ARCH=linux/arm64,linux/amd64 +# OUTPUT="--push" ## -------------------------------------------------------------- ## | build | ## -------------------------------------------------------------- -docker buildx use default +# multiplatform builder +BUILDER=container-builder + +# get info about an existing builder +container_builder_info=$(docker buildx inspect ${BUILDER}) + +if [[ "$?" == "0" ]]; then + # activate the builder if it exists + docker buildx use ${BUILDER} +else + # create the builder if it does not exist + docker buildx create --name ${BUILDER} --driver docker-container --bootstrap --use +fi -docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=linux/${ARCH} +# build the docker image using the builder and export the results to the local docker registry +docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=${ARCH} ${OUTPUT} echo "" echo "$0: shared data were packed into '$LOCAL_TAG'" diff --git a/docker/shared_data/gnss/build_image.sh b/docker/shared_data/gnss/build_image.sh index 677f6c3..f8ac7c2 100755 --- a/docker/shared_data/gnss/build_image.sh +++ b/docker/shared_data/gnss/build_image.sh @@ -1,10 +1,5 @@ #!/bin/bash -set -e - -trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG -trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR - # get the path to this script MY_PATH=`dirname "$0"` MY_PATH=`( cd "$MY_PATH" && pwd )` @@ -18,16 +13,35 @@ cd ${MY_PATH} LOCAL_TAG=robofly:shared_data_gnss REGISTRY=fly4future -ARCH=arm64 # robofly -# ARCH=amd64 +# single-platform image can be stored locally +# ARCH=linux/amd64 +ARCH=linux/arm64 +OUTPUT="--output type=docker" + +# multi-platform image can not be stored locally, needs to be pushed +# ARCH=linux/arm64,linux/amd64 +# OUTPUT="--push" ## -------------------------------------------------------------- ## | build | ## -------------------------------------------------------------- -docker buildx use default +# multiplatform builder +BUILDER=container-builder + +# get info about an existing builder +container_builder_info=$(docker buildx inspect ${BUILDER}) + +if [[ "$?" == "0" ]]; then + # activate the builder if it exists + docker buildx use ${BUILDER} +else + # create the builder if it does not exist + docker buildx create --name ${BUILDER} --driver docker-container --bootstrap --use +fi -docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=linux/${ARCH} --no-cache +# build the docker image using the builder and export the results to the local docker registry +docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=${ARCH} ${OUTPUT} echo "" echo "$0: shared data were packed into '$LOCAL_TAG'" diff --git a/docker/shared_data/vio/build_image.sh b/docker/shared_data/vio/build_image.sh index 329c0a2..abd993d 100755 --- a/docker/shared_data/vio/build_image.sh +++ b/docker/shared_data/vio/build_image.sh @@ -1,10 +1,5 @@ #!/bin/bash -set -e - -trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG -trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR - # get the path to this script MY_PATH=`dirname "$0"` MY_PATH=`( cd "$MY_PATH" && pwd )` @@ -18,16 +13,35 @@ cd ${MY_PATH} LOCAL_TAG=robofly:shared_data_vio REGISTRY=fly4future -ARCH=arm64 # robofly -# ARCH=amd64 +# single-platform image can be stored locally +# ARCH=linux/amd64 +ARCH=linux/arm64 +OUTPUT="--output type=docker" + +# multi-platform image can not be stored locally, needs to be pushed +# ARCH=linux/arm64,linux/amd64 +# OUTPUT="--push" ## -------------------------------------------------------------- ## | build | ## -------------------------------------------------------------- -docker buildx use default +# multiplatform builder +BUILDER=container-builder + +# get info about an existing builder +container_builder_info=$(docker buildx inspect ${BUILDER}) + +if [[ "$?" == "0" ]]; then + # activate the builder if it exists + docker buildx use ${BUILDER} +else + # create the builder if it does not exist + docker buildx create --name ${BUILDER} --driver docker-container --bootstrap --use +fi -docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=linux/${ARCH} +# build the docker image using the builder and export the results to the local docker registry +docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=${ARCH} ${OUTPUT} echo "" echo "$0: shared data were packed into '$LOCAL_TAG'"