From b5621f896437990b03f4085fa7e258b0481cab1f Mon Sep 17 00:00:00 2001 From: Steffen Planthaber Date: Thu, 3 Dec 2020 12:59:27 +0100 Subject: [PATCH 01/10] add cross dev section in docker setup --- doc/010_Setup_Docker.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/010_Setup_Docker.md b/doc/010_Setup_Docker.md index 2771d44..f4a3cb9 100644 --- a/doc/010_Setup_Docker.md +++ b/doc/010_Setup_Docker.md @@ -92,6 +92,24 @@ In order to make sure that the kernel modules are properly loaded, you should re Now you are ready to use docker! +### Cross Development for docker images + +To develop for arm-based boards on x86, you can enable your host machine execute non-native binary formats using [QEMU](https://www.qemu.org) and [binfmt_misc](https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html). + +When this is set up, docker is able to run images for the architectures supported by QEMU on your host machine (using CPU emulation). + +There is a docker image that can do the settings for you: [see here](https://github.com/multiarch/qemu-user-static) + +Quick enable: + + sudo apt-get install qemu binfmt-support qemu-user-static + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + +Test it using e.g. + + docker run --rm -ti arm64v8/ubuntu uname -m + + ### Using a registry If you want to use the image generated by the docker build from this repository, you can also use the already build image from the registry server. From ebebc056bac26c2791fd74bd55bac52f20994ffe Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Thu, 3 Dec 2020 16:51:47 +0100 Subject: [PATCH 02/10] push non functional update to debug multiarch mount --- image_setup/01_base_images/Dockerfile | 11 +++++----- .../build_ros_noetic_20.04.bash | 20 ++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/image_setup/01_base_images/Dockerfile b/image_setup/01_base_images/Dockerfile index b72f8c8..728005b 100644 --- a/image_setup/01_base_images/Dockerfile +++ b/image_setup/01_base_images/Dockerfile @@ -14,16 +14,15 @@ ENV DEBIAN_FRONTEND=noninteractive # general requirements RUN apt-get update && apt-get install -y \ - build-essential \ apt-utils \ - git \ - wget \ - cmake \ - sudo \ + build-essential \ cmake \ + git \ + locales \ python3 \ python3-dev \ - locales + sudo \ + wget RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index 7d5ea25..8c35737 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -1,14 +1,28 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 + +export ARCH=${1:-x86_64} +# set architecture depending on passed argument +# available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ]; then + export BASE_IMAGE=arm64v8/ubuntu:focal + echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported.\n Currently only x86_64 and arm64v8 are supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/$ARCH/ros_noetic_20.04 export INSTALL_SCRIPT=install_ros_dependencies.bash export INSTALL_ARGS=noetic docker pull $BASE_IMAGE -docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . +docker build -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . +#docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . From 066fcd9599861bd81412fbb1db2da894ac6eff8b Mon Sep 17 00:00:00 2001 From: Steffen Planthaber Date: Thu, 3 Dec 2020 17:44:33 +0100 Subject: [PATCH 03/10] fix qemu doc to be able to mount properly --- doc/010_Setup_Docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/010_Setup_Docker.md b/doc/010_Setup_Docker.md index f4a3cb9..a087f1d 100644 --- a/doc/010_Setup_Docker.md +++ b/doc/010_Setup_Docker.md @@ -103,7 +103,7 @@ There is a docker image that can do the settings for you: [see here](https://git Quick enable: sudo apt-get install qemu binfmt-support qemu-user-static - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes Test it using e.g. From aad08192e549f50a97f55d4c34e5a708133028b2 Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Thu, 3 Dec 2020 18:27:35 +0100 Subject: [PATCH 04/10] Cleanup multiarch approach and setup install scripts for ros on arm64 --- docker_commands.bash | 2 +- image_setup/01_base_images/Dockerfile | 4 +-- .../arm64v8/install_ros_dependencies.bash | 28 +++++++++++++++++ .../install_ros_minimal_dependencies.bash | 30 +++++++++++++++++++ .../01_base_images/build_plain_18.04.bash | 16 ++++++++-- .../01_base_images/build_plain_20.04.bash | 16 ++++++++-- .../build_rock_master_16.04.bash | 13 ++++++-- .../build_rock_master_18.04.bash | 13 ++++++-- .../build_ros_melodic_18.04.bash | 14 ++++++--- .../build_ros_melodic_18.04_minimal.bash | 14 ++++++--- .../build_ros_noetic_20.04.bash | 15 ++++------ .../build_ros_noetic_20.04_minimal.bash | 17 ++++++++--- .../install_plain_dependencies.bash | 15 ++-------- .../install_ros_minimal_dependencies.bash | 6 ++-- settings.bash | 6 ++++ 15 files changed, 156 insertions(+), 53 deletions(-) create mode 100644 image_setup/01_base_images/arm64v8/install_ros_dependencies.bash create mode 100644 image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash diff --git a/docker_commands.bash b/docker_commands.bash index 30c062f..35cba87 100755 --- a/docker_commands.bash +++ b/docker_commands.bash @@ -22,7 +22,7 @@ init_docker(){ touch $GPUS_SETTINGS_FILE docker run --gpus=all --rm $IMAGE_NAME > /dev/null GPU_SUPPORTED=$? - echo "this file contains the gegerated result of testing the docker --gpu setting, 0=enabled, 1=disabled" > $GPUS_SETTINGS_FILE + echo "this file contains the generated result of testing the docker --gpu setting, 0=enabled, 1=disabled" > $GPUS_SETTINGS_FILE echo $GPU_SUPPORTED >> $GPUS_SETTINGS_FILE fi HAS_GPU_SUPPORT=$(tail -n1 $GPUS_SETTINGS_FILE) diff --git a/image_setup/01_base_images/Dockerfile b/image_setup/01_base_images/Dockerfile index 728005b..071989e 100644 --- a/image_setup/01_base_images/Dockerfile +++ b/image_setup/01_base_images/Dockerfile @@ -38,13 +38,13 @@ RUN /opt/install.bash ${INSTALL_ARGS} ADD init_user_id.bash /opt/init_user_id.bash -# create user (usermod -u UID username will be used later to maybe adapt UID on fitst start). +# create user (usermod -u UID username will be used later to maybe adapt UID on first start). # using salted password: openssl passwd -1 -salt xyz yourpass # pw UserRos # RUN useradd -m -U -p '$1$xyz$pzVfEx0ZWLPizymvlx2P70' -G sudo,users rosuser RUN groupadd devel-group RUN useradd --shell /bin/bash -c "development user" -m -G devel-group devel -# set user sudoers previlege for start script (w/o password), the /opt/init_user_id.bash script +# set user sudoers privilege for start script (w/o password), the /opt/init_user_id.bash script # is using NUID and NGID environment variables, but ist executed by the user using sudo, so these vars have to be kept RUN echo "devel ALL=(ALL) NOPASSWD: ALL \ \nDefaults env_keep += \"NUID\" \ diff --git a/image_setup/01_base_images/arm64v8/install_ros_dependencies.bash b/image_setup/01_base_images/arm64v8/install_ros_dependencies.bash new file mode 100644 index 0000000..4043c30 --- /dev/null +++ b/image_setup/01_base_images/arm64v8/install_ros_dependencies.bash @@ -0,0 +1,28 @@ +#!/bin/bash + +#install ROS melodic (second install because needs gnupg) +export DEBIAN_FRONTEND=noninteractive + +DISTRO=${1:-melodic} +[ $DISTRO == "noetic" ] && export vPYTHON=3 + +apt-get update && apt-get install -y \ + lsb-release \ + gnupg2 \ + gosu \ + ruby \ + ruby-dev \ + python$vPYTHON + +sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +apt-get update && apt-get install -y \ + ros-desktop \ + python$vPYTHON-catkin-pkg \ + python$vPYTHON-rosdep2 \ + python$vPYTHON-rosinstall \ + python$vPYTHON-rosinstall-generator \ + python$vPYTHON-wstool + + +#rosdep init && rosdep update diff --git a/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash b/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash new file mode 100644 index 0000000..92cb00b --- /dev/null +++ b/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +#install ROS melodic (second install because needs gnupg) +export DEBIAN_FRONTEND=noninteractive + +DISTRO=${1:-melodic} +[ $DISTRO == "noetic" ] && export vPYTHON=3 + +apt-get update && apt-get install -y \ + lsb-release \ + gnupg2 \ + gosu \ + ruby \ + ruby-dev \ + python$vPYTHON + +sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +apt-get update && apt-get install -y \ + ros-base \ + python$vPYTHON-catkin-pkg \ + python$vPYTHON-rosdep2 \ + python$vPYTHON-rosinstall \ + python$vPYTHON-rosinstall-generator \ + python$vPYTHON-wstool + + +#rosdep init && rosdep update + + diff --git a/image_setup/01_base_images/build_plain_18.04.bash b/image_setup/01_base_images/build_plain_18.04.bash index 6b01678..0c51959 100755 --- a/image_setup/01_base_images/build_plain_18.04.bash +++ b/image_setup/01_base_images/build_plain_18.04.bash @@ -1,16 +1,26 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_18.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ]; then + export BASE_IMAGE=arm64v8/ubuntu:bionic + echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_18.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_plain_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_plain_20.04.bash b/image_setup/01_base_images/build_plain_20.04.bash index 52ae381..6769bed 100755 --- a/image_setup/01_base_images/build_plain_20.04.bash +++ b/image_setup/01_base_images/build_plain_20.04.bash @@ -1,16 +1,26 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_20.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ]; then + export BASE_IMAGE=arm64v8/ubuntu:focal + echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_20.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_plain_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_rock_master_16.04.bash b/image_setup/01_base_images/build_rock_master_16.04.bash index c6f20e2..1ca23de 100755 --- a/image_setup/01_base_images/build_rock_master_16.04.bash +++ b/image_setup/01_base_images/build_rock_master_16.04.bash @@ -1,16 +1,23 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_16.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu16.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu16.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_16.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_rock_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_rock_master_18.04.bash b/image_setup/01_base_images/build_rock_master_18.04.bash index 7a63c6b..d6a3b46 100755 --- a/image_setup/01_base_images/build_rock_master_18.04.bash +++ b/image_setup/01_base_images/build_rock_master_18.04.bash @@ -1,16 +1,23 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_18.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_18.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_rock_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_ros_melodic_18.04.bash b/image_setup/01_base_images/build_ros_melodic_18.04.bash index aad4b6e..86cdc57 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04.bash @@ -1,18 +1,24 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04 -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" echo - diff --git a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash index 47d4d6b..d139411 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash @@ -1,18 +1,24 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04_minimal -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04_minimal +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" echo - diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index 8c35737..a41b0d9 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -2,10 +2,7 @@ . ../../settings.bash - -export ARCH=${1:-x86_64} -# set architecture depending on passed argument -# available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 +# manage base image name depending on selected $ARCH in settings.bash if [ $ARCH == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." @@ -13,21 +10,19 @@ elif [ $ARCH == "arm64v8" ]; then export BASE_IMAGE=arm64v8/ubuntu:focal echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported.\n Currently only x86_64 and arm64v8 are supported." && exit 1 + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/$ARCH/ros_noetic_20.04 +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04 +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_dependencies.bash export INSTALL_ARGS=noetic docker pull $BASE_IMAGE -docker build -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . -#docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . - +docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" echo - diff --git a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash index 8221e9d..9eaf5c4 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash @@ -1,9 +1,20 @@ #!/bin/bash . ../../settings.bash -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04_minimal -export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 +# manage base image name depending on selected $ARCH in settings.bash +if [ $ARCH == "x86_64" ]; then + export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 + echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ]; then + export BASE_IMAGE=arm64v8/ubuntu:focal + echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +else + echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 +fi + +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04_minimal +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash export INSTALL_ARGS=noetic @@ -11,9 +22,7 @@ docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" echo - diff --git a/image_setup/01_base_images/install_plain_dependencies.bash b/image_setup/01_base_images/install_plain_dependencies.bash index c708786..fb43b93 100644 --- a/image_setup/01_base_images/install_plain_dependencies.bash +++ b/image_setup/01_base_images/install_plain_dependencies.bash @@ -1,15 +1,4 @@ #!/bin/bash -#install ROS melodic (second install because needs gnupg) -export DEBIAN_FRONTEND=noninteractive - -# apt-get update && apt-get install -y \ -# lsb-release \ -# gnupg2 \ -# gosu \ -# ruby \ -# ruby-dev \ -# python - - - +# this script remains empty for now as all essential packages +# for the plain base images are listed directly in the Dockerfile diff --git a/image_setup/01_base_images/install_ros_minimal_dependencies.bash b/image_setup/01_base_images/install_ros_minimal_dependencies.bash index f464083..27ed227 100644 --- a/image_setup/01_base_images/install_ros_minimal_dependencies.bash +++ b/image_setup/01_base_images/install_ros_minimal_dependencies.bash @@ -18,11 +18,11 @@ sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > / apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 apt-get update && apt-get install -y \ ros-$DISTRO-ros-base \ + python$vPYTHON-catkin-tools \ + python$vPYTHON-rosdep \ python$vPYTHON-rosinstall \ python$vPYTHON-rosinstall-generator \ - python$vPYTHON-wstool \ - python$vPYTHON-rosdep \ - python$vPYTHON-catkin-tools + python$vPYTHON-wstool #rosdep init && rosdep update diff --git a/settings.bash b/settings.bash index 689d779..3c653e8 100755 --- a/settings.bash +++ b/settings.bash @@ -47,3 +47,9 @@ export WORKSPACE_RELEASE_IMAGE=developmentimage/${PROJECT_NAME}:release # --privileged # -v /dev/input/:/dev/input export ADDITIONAL_DOCKER_RUN_ARGS="" + +# set desired processor architecture for image build +# available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 +# default: x86_64 +# supported alternatives: arm64v8 +export ARCH="arm64v8" From 90fd75df42ebc80a6590c91054b455ec2a81cde8 Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Fri, 4 Dec 2020 10:04:32 +0100 Subject: [PATCH 05/10] Fix install script location for alternativ architectures --- doc/010_Setup_Docker.md | 2 +- image_setup/01_base_images/build_plain_18.04.bash | 3 ++- image_setup/01_base_images/build_plain_20.04.bash | 3 ++- image_setup/01_base_images/build_rock_master_16.04.bash | 3 ++- image_setup/01_base_images/build_rock_master_18.04.bash | 3 ++- image_setup/01_base_images/build_ros_melodic_18.04.bash | 3 ++- .../01_base_images/build_ros_melodic_18.04_minimal.bash | 3 ++- image_setup/01_base_images/build_ros_noetic_20.04.bash | 3 ++- image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash | 3 ++- 9 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/010_Setup_Docker.md b/doc/010_Setup_Docker.md index a087f1d..e9a94ce 100644 --- a/doc/010_Setup_Docker.md +++ b/doc/010_Setup_Docker.md @@ -103,7 +103,7 @@ There is a docker image that can do the settings for you: [see here](https://git Quick enable: sudo apt-get install qemu binfmt-support qemu-user-static - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes Test it using e.g. diff --git a/image_setup/01_base_images/build_plain_18.04.bash b/image_setup/01_base_images/build_plain_18.04.bash index 0c51959..f64d797 100755 --- a/image_setup/01_base_images/build_plain_18.04.bash +++ b/image_setup/01_base_images/build_plain_18.04.bash @@ -14,8 +14,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_18.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_plain_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_plain_20.04.bash b/image_setup/01_base_images/build_plain_20.04.bash index 6769bed..33a8eaa 100755 --- a/image_setup/01_base_images/build_plain_20.04.bash +++ b/image_setup/01_base_images/build_plain_20.04.bash @@ -14,8 +14,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_20.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_plain_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_rock_master_16.04.bash b/image_setup/01_base_images/build_rock_master_16.04.bash index 1ca23de..5c05910 100755 --- a/image_setup/01_base_images/build_rock_master_16.04.bash +++ b/image_setup/01_base_images/build_rock_master_16.04.bash @@ -11,8 +11,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_16.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_rock_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_rock_master_18.04.bash b/image_setup/01_base_images/build_rock_master_18.04.bash index d6a3b46..96a6d47 100755 --- a/image_setup/01_base_images/build_rock_master_18.04.bash +++ b/image_setup/01_base_images/build_rock_master_18.04.bash @@ -11,8 +11,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_18.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_rock_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_ros_melodic_18.04.bash b/image_setup/01_base_images/build_ros_melodic_18.04.bash index 86cdc57..8ed22b3 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04.bash @@ -11,8 +11,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash index d139411..a5ee735 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash @@ -11,8 +11,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04_minimal -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index a41b0d9..ec7536b 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -14,8 +14,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04 -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT export INSTALL_ARGS=noetic docker pull $BASE_IMAGE diff --git a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash index 9eaf5c4..1a50041 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash @@ -14,8 +14,9 @@ else fi export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04_minimal -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash +[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT export INSTALL_ARGS=noetic docker pull $BASE_IMAGE From c6ab717ae1380e4cee141a1a1726d8e1f3f24009 Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Fri, 4 Dec 2020 10:06:15 +0100 Subject: [PATCH 06/10] Adapt higher image builds to alternative archs. use consistent image_name syntax in build.bash --- image_setup/02_devel_image/Dockerfile | 7 ------- image_setup/02_devel_image/build.bash | 5 ++++- image_setup/03_release_image/build.bash | 16 +++++++++------- image_setup/04_save_release/build.bash | 3 ++- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/image_setup/02_devel_image/Dockerfile b/image_setup/02_devel_image/Dockerfile index 1782ee4..b53d3e4 100644 --- a/image_setup/02_devel_image/Dockerfile +++ b/image_setup/02_devel_image/Dockerfile @@ -20,10 +20,3 @@ RUN echo "echo" >> /opt/init_workspace.bash # If you want to run the setup automatically, you can add it directly to the script # it is executed every time the container is re-created #RUN echo "/opt/setup_workspace.sh" >> /opt/init_workspace.sh - - - - - - - diff --git a/image_setup/02_devel_image/build.bash b/image_setup/02_devel_image/build.bash index bf30c9b..4282d7e 100644 --- a/image_setup/02_devel_image/build.bash +++ b/image_setup/02_devel_image/build.bash @@ -2,9 +2,12 @@ . ../../settings.bash export BASE_IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}$WORKSPACE_BASE_IMAGE - IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE +[ "$ARCH" != "x86_64" ] && export BASE_IMAGE_NAME=$(dirname $BASE_IMAGE_NAME)/$ARCH/$(basename $BASE_IMAGE_NAME) +[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) + + if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then echo echo pulling image: $BASE_IMAGE_NAME diff --git a/image_setup/03_release_image/build.bash b/image_setup/03_release_image/build.bash index 5ebdef7..281723c 100644 --- a/image_setup/03_release_image/build.bash +++ b/image_setup/03_release_image/build.bash @@ -5,21 +5,23 @@ export DATE=$(date) export TAG=$(date +%Y_%m_%d-%H_%M) export HOST=$(hostname) export DEVEL_IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE +[ "$ARCH" != "x86_64" ] && export DEVEL_IMAGE_NAME=$(dirname $DEVEL_IMAGE_NAME)/$ARCH/$(basename $DEVEL_IMAGE_NAME) #if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then #do not pull for release, use the local image, as the release should be based on the exact same devel image #fi -RELEASE_IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE -echo "Buidling release image: ${RELEASE_IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE" +IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE +[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) +echo "Buidling release image: ${IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE" -docker build --no-cache --build-arg DEVEL_IMAGE_NAME --build-arg USER --build-arg HOST --build-arg DATE -f Dockerfile -t $RELEASE_IMAGE_NAME ../.. +docker build --no-cache --build-arg DEVEL_IMAGE_NAME --build-arg USER --build-arg HOST --build-arg DATE -f Dockerfile -t $IMAGE_NAME ../.. -echo "tagging $RELEASE_IMAGE_NAME as ${RELEASE_IMAGE_NAME}_$TAG" -docker tag $RELEASE_IMAGE_NAME ${RELEASE_IMAGE_NAME}_$TAG +echo "tagging $IMAGE_NAME as ${IMAGE_NAME}_$TAG" +docker tag $IMAGE_NAME ${IMAGE_NAME}_$TAG echo echo "don't forget to push the image if you wish:" -echo "docker push $RELEASE_IMAGE_NAME" -echo "docker push ${RELEASE_IMAGE_NAME}_$TAG" +echo "docker push $IMAGE_NAME" +echo "docker push ${IMAGE_NAME}_$TAG" echo diff --git a/image_setup/04_save_release/build.bash b/image_setup/04_save_release/build.bash index 1d25b86..992c5cd 100644 --- a/image_setup/04_save_release/build.bash +++ b/image_setup/04_save_release/build.bash @@ -12,10 +12,11 @@ export DATE=$(date +%Y_%m_%d-%H_%M) PROJECT_NAME_NO_SUBFOLDER=${PROJECT_NAME//\//_} IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE +[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) SCRIPTFOLDER=${PROJECT_NAME_NO_SUBFOLDER}_scripts_${DATE} mkdir -p $SCRIPTFOLDER -#build a scripts zip: +# build a scripts zip: echo "creating scripts archive: $SCRIPTFOLDER.tar.gz" cp ../../docker_commands.bash ./$SCRIPTFOLDER/ cp ../../settings.bash ./$SCRIPTFOLDER/ From 74d7b15e210bb3f76cf400ead5cf9fe866caff3e Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Fri, 4 Dec 2020 11:56:20 +0100 Subject: [PATCH 07/10] Add support for arm32v7 and update exec to support multi-arch --- exec.bash | 3 ++ .../arm32v7/install_ros_dependencies.bash | 28 +++++++++++++++++ .../install_ros_minimal_dependencies.bash | 30 +++++++++++++++++++ .../01_base_images/build_plain_18.04.bash | 3 ++ .../01_base_images/build_plain_20.04.bash | 3 ++ .../build_ros_noetic_20.04.bash | 3 ++ settings.bash | 4 +-- 7 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 image_setup/01_base_images/arm32v7/install_ros_dependencies.bash create mode 100644 image_setup/01_base_images/arm32v7/install_ros_minimal_dependencies.bash diff --git a/exec.bash b/exec.bash index 2cb0063..d3528d9 100755 --- a/exec.bash +++ b/exec.bash @@ -32,6 +32,7 @@ fi if [ "$EXECMODE" == "base" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}$WORKSPACE_BASE_IMAGE + [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) HOST_WORKSPACE=$(pwd) mkdir -p $HOST_WORKSPACE/workspace mkdir -p $HOST_WORKSPACE/home @@ -45,6 +46,7 @@ fi if [ "$EXECMODE" = "devel" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE + [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) HOST_WORKSPACE=$(pwd) #in case the devel image is pulled, we need the create the folders here mkdir -p $HOST_WORKSPACE/workspace @@ -58,6 +60,7 @@ fi if [ "$EXECMODE" == "release" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE + [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) fi if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then diff --git a/image_setup/01_base_images/arm32v7/install_ros_dependencies.bash b/image_setup/01_base_images/arm32v7/install_ros_dependencies.bash new file mode 100644 index 0000000..4043c30 --- /dev/null +++ b/image_setup/01_base_images/arm32v7/install_ros_dependencies.bash @@ -0,0 +1,28 @@ +#!/bin/bash + +#install ROS melodic (second install because needs gnupg) +export DEBIAN_FRONTEND=noninteractive + +DISTRO=${1:-melodic} +[ $DISTRO == "noetic" ] && export vPYTHON=3 + +apt-get update && apt-get install -y \ + lsb-release \ + gnupg2 \ + gosu \ + ruby \ + ruby-dev \ + python$vPYTHON + +sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +apt-get update && apt-get install -y \ + ros-desktop \ + python$vPYTHON-catkin-pkg \ + python$vPYTHON-rosdep2 \ + python$vPYTHON-rosinstall \ + python$vPYTHON-rosinstall-generator \ + python$vPYTHON-wstool + + +#rosdep init && rosdep update diff --git a/image_setup/01_base_images/arm32v7/install_ros_minimal_dependencies.bash b/image_setup/01_base_images/arm32v7/install_ros_minimal_dependencies.bash new file mode 100644 index 0000000..92cb00b --- /dev/null +++ b/image_setup/01_base_images/arm32v7/install_ros_minimal_dependencies.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +#install ROS melodic (second install because needs gnupg) +export DEBIAN_FRONTEND=noninteractive + +DISTRO=${1:-melodic} +[ $DISTRO == "noetic" ] && export vPYTHON=3 + +apt-get update && apt-get install -y \ + lsb-release \ + gnupg2 \ + gosu \ + ruby \ + ruby-dev \ + python$vPYTHON + +sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +apt-get update && apt-get install -y \ + ros-base \ + python$vPYTHON-catkin-pkg \ + python$vPYTHON-rosdep2 \ + python$vPYTHON-rosinstall \ + python$vPYTHON-rosinstall-generator \ + python$vPYTHON-wstool + + +#rosdep init && rosdep update + + diff --git a/image_setup/01_base_images/build_plain_18.04.bash b/image_setup/01_base_images/build_plain_18.04.bash index f64d797..2b6f033 100755 --- a/image_setup/01_base_images/build_plain_18.04.bash +++ b/image_setup/01_base_images/build_plain_18.04.bash @@ -9,6 +9,9 @@ if [ $ARCH == "x86_64" ]; then elif [ $ARCH == "arm64v8" ]; then export BASE_IMAGE=arm64v8/ubuntu:bionic echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=arm32v7/ubuntu:bionic + echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/image_setup/01_base_images/build_plain_20.04.bash b/image_setup/01_base_images/build_plain_20.04.bash index 33a8eaa..5ff139a 100755 --- a/image_setup/01_base_images/build_plain_20.04.bash +++ b/image_setup/01_base_images/build_plain_20.04.bash @@ -9,6 +9,9 @@ if [ $ARCH == "x86_64" ]; then elif [ $ARCH == "arm64v8" ]; then export BASE_IMAGE=arm64v8/ubuntu:focal echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=arm32v7/ubuntu:focal + echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index ec7536b..d713664 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -9,6 +9,9 @@ if [ $ARCH == "x86_64" ]; then elif [ $ARCH == "arm64v8" ]; then export BASE_IMAGE=arm64v8/ubuntu:focal echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=arm32v7/ubuntu:focal + echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/settings.bash b/settings.bash index 3c653e8..8f9870a 100755 --- a/settings.bash +++ b/settings.bash @@ -51,5 +51,5 @@ export ADDITIONAL_DOCKER_RUN_ARGS="" # set desired processor architecture for image build # available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 # default: x86_64 -# supported alternatives: arm64v8 -export ARCH="arm64v8" +# partially supported alternatives: arm32v7, arm64v8 +export ARCH="arm32v7" From 76dfbce3fdc999698df2714e3359663e4c7c50f4 Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Thu, 10 Dec 2020 17:15:32 +0100 Subject: [PATCH 08/10] Make image selection based on architecture more generic --- image_setup/01_base_images/build_plain_18.04.bash | 9 +++------ image_setup/01_base_images/build_plain_20.04.bash | 9 +++------ image_setup/01_base_images/build_ros_noetic_20.04.bash | 9 +++------ .../01_base_images/build_ros_noetic_20.04_minimal.bash | 6 +++--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/image_setup/01_base_images/build_plain_18.04.bash b/image_setup/01_base_images/build_plain_18.04.bash index 2b6f033..99a69fd 100755 --- a/image_setup/01_base_images/build_plain_18.04.bash +++ b/image_setup/01_base_images/build_plain_18.04.bash @@ -6,12 +6,9 @@ if [ $ARCH == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ]; then - export BASE_IMAGE=arm64v8/ubuntu:bionic - echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=arm32v7/ubuntu:bionic - echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/image_setup/01_base_images/build_plain_20.04.bash b/image_setup/01_base_images/build_plain_20.04.bash index 5ff139a..3575d9f 100755 --- a/image_setup/01_base_images/build_plain_20.04.bash +++ b/image_setup/01_base_images/build_plain_20.04.bash @@ -6,12 +6,9 @@ if [ $ARCH == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ]; then - export BASE_IMAGE=arm64v8/ubuntu:focal - echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=arm32v7/ubuntu:focal - echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index d713664..bdef863 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -6,12 +6,9 @@ if [ $ARCH == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ]; then - export BASE_IMAGE=arm64v8/ubuntu:focal - echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=arm32v7/ubuntu:focal - echo "Building for arm32v7 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi diff --git a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash index 1a50041..20198d4 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash @@ -6,9 +6,9 @@ if [ $ARCH == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ]; then - export BASE_IMAGE=arm64v8/ubuntu:focal - echo "Building for arm64v8 processor. Using $BASE_IMAGE as base image." +elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi From e545857ef67d200747e2b6b06e086b118b636332 Mon Sep 17 00:00:00 2001 From: Leon Cedric Danter Date: Mon, 18 Jan 2021 11:11:50 +0100 Subject: [PATCH 09/10] Fix image name handling with ARCH and handle empty DNSIP --- exec.bash | 5 +--- .../install_ros_minimal_dependencies.bash | 2 -- .../01_base_images/build_plain_18.04.bash | 13 +++------- .../01_base_images/build_plain_20.04.bash | 15 ++++------- .../build_rock_master_16.04.bash | 12 ++++----- .../build_rock_master_18.04.bash | 12 ++++----- .../build_ros_melodic_18.04.bash | 12 ++++----- .../build_ros_melodic_18.04_minimal.bash | 12 ++++----- .../build_ros_noetic_20.04.bash | 15 ++++------- .../build_ros_noetic_20.04_minimal.bash | 15 ++++------- image_setup/02_devel_image/build.bash | 5 ---- image_setup/03_release_image/build.bash | 2 -- image_setup/04_save_release/build.bash | 3 --- settings.bash | 26 +++++++++---------- 14 files changed, 52 insertions(+), 97 deletions(-) diff --git a/exec.bash b/exec.bash index d3528d9..824987a 100755 --- a/exec.bash +++ b/exec.bash @@ -32,7 +32,6 @@ fi if [ "$EXECMODE" == "base" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}$WORKSPACE_BASE_IMAGE - [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) HOST_WORKSPACE=$(pwd) mkdir -p $HOST_WORKSPACE/workspace mkdir -p $HOST_WORKSPACE/home @@ -46,7 +45,6 @@ fi if [ "$EXECMODE" = "devel" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE - [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) HOST_WORKSPACE=$(pwd) #in case the devel image is pulled, we need the create the folders here mkdir -p $HOST_WORKSPACE/workspace @@ -60,7 +58,6 @@ fi if [ "$EXECMODE" == "release" ]; then # DOCKER_REGISTRY and WORKSPACE_DEVEL_IMAGE from settings.bash IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE - [ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) fi if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then @@ -101,7 +98,7 @@ DOCKER_RUN_ARGS=" \ --name $CONTAINER_NAME \ -e NUID=$(id -u) -e NGID=$(id -g) \ -u devel \ - --dns $DNSIP \ + ${DNSIP:+--dns $DNSIP} \ -e DISPLAY -e QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix \ $ADDITIONAL_DOCKER_RUN_ARGS \ $ADDITIONAL_DOCKER_MOUNT_ARGS \ diff --git a/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash b/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash index 92cb00b..71aa20e 100644 --- a/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash +++ b/image_setup/01_base_images/arm64v8/install_ros_minimal_dependencies.bash @@ -26,5 +26,3 @@ apt-get update && apt-get install -y \ #rosdep init && rosdep update - - diff --git a/image_setup/01_base_images/build_plain_18.04.bash b/image_setup/01_base_images/build_plain_18.04.bash index 99a69fd..b29abfc 100755 --- a/image_setup/01_base_images/build_plain_18.04.bash +++ b/image_setup/01_base_images/build_plain_18.04.bash @@ -3,25 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then +else export BASE_IMAGE=$ARCH/ubuntu:bionic echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." -else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_18.04 -export INSTALL_SCRIPT=install_plain_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}plain_18.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_plain_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_plain_20.04.bash b/image_setup/01_base_images/build_plain_20.04.bash index 3575d9f..339a363 100755 --- a/image_setup/01_base_images/build_plain_20.04.bash +++ b/image_setup/01_base_images/build_plain_20.04.bash @@ -3,25 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=$ARCH/ubuntu:bionic - echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:focal + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/plain_20.04 -export INSTALL_SCRIPT=install_plain_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}plain_20.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_plain_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_rock_master_16.04.bash b/image_setup/01_base_images/build_rock_master_16.04.bash index 5c05910..6391f16 100755 --- a/image_setup/01_base_images/build_rock_master_16.04.bash +++ b/image_setup/01_base_images/build_rock_master_16.04.bash @@ -3,22 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu16.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:xenial + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_16.04 -export INSTALL_SCRIPT=install_rock_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}rock_master_16.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_rock_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_rock_master_18.04.bash b/image_setup/01_base_images/build_rock_master_18.04.bash index 96a6d47..f59bcba 100755 --- a/image_setup/01_base_images/build_rock_master_18.04.bash +++ b/image_setup/01_base_images/build_rock_master_18.04.bash @@ -3,22 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/rock_master_18.04 -export INSTALL_SCRIPT=install_rock_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}rock_master_18.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_rock_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_ros_melodic_18.04.bash b/image_setup/01_base_images/build_ros_melodic_18.04.bash index 8ed22b3..f8ed5f8 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04.bash @@ -3,22 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04 -export INSTALL_SCRIPT=install_ros_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}ros_melodic_18.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_ros_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash index a5ee735..d75b1a7 100755 --- a/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_melodic_18.04_minimal.bash @@ -3,22 +3,20 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:bionic + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_melodic_18.04_minimal -export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}ros_melodic_18.04_minimal +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_ros_minimal_dependencies.bash docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_ros_noetic_20.04.bash b/image_setup/01_base_images/build_ros_noetic_20.04.bash index bdef863..7c7430e 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04.bash @@ -3,26 +3,21 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=$ARCH/ubuntu:bionic - echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:focal + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04 -export INSTALL_SCRIPT=install_ros_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}ros_noetic_20.04 +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_ros_dependencies.bash export INSTALL_ARGS=noetic docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash index 20198d4..25f830a 100755 --- a/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash +++ b/image_setup/01_base_images/build_ros_noetic_20.04_minimal.bash @@ -3,26 +3,21 @@ . ../../settings.bash # manage base image name depending on selected $ARCH in settings.bash -if [ $ARCH == "x86_64" ]; then +if [ "$ARCH" == "" ] || [ "$ARCH" == "x86_64" ]; then export BASE_IMAGE=nvidia/opengl:1.0-glvnd-devel-ubuntu20.04 echo "Building for x86_64 processor. Using $BASE_IMAGE as base image." -elif [ $ARCH == "arm64v8" ] || [ $ARCH == "arm32v7" ]; then - export BASE_IMAGE=$ARCH/ubuntu:bionic - echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." else - echo -e "[ERROR] The processor architecture you selected ($ARCH) is not supported." && exit 1 + export BASE_IMAGE=$ARCH/ubuntu:focal + echo "Building for $ARCH processor. Using $BASE_IMAGE as base image." fi -export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/ros_noetic_20.04_minimal -export INSTALL_SCRIPT=install_ros_minimal_dependencies.bash -[ "$ARCH" != "x86_64" ] && export IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && export INSTALL_SCRIPT=$ARCH/$INSTALL_SCRIPT +export IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}developmentimage/${ARCH:+$ARCH/}ros_noetic_20.04_minimal +export INSTALL_SCRIPT=${ARCH:+$ARCH/}install_ros_minimal_dependencies.bash export INSTALL_ARGS=noetic docker pull $BASE_IMAGE docker build --no-cache -f Dockerfile -t $IMAGE_NAME:base --build-arg BASE_IMAGE --build-arg INSTALL_SCRIPT --build-arg INSTALL_ARGS . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME:base" diff --git a/image_setup/02_devel_image/build.bash b/image_setup/02_devel_image/build.bash index 4282d7e..204b302 100644 --- a/image_setup/02_devel_image/build.bash +++ b/image_setup/02_devel_image/build.bash @@ -4,10 +4,6 @@ export BASE_IMAGE_NAME=${BASE_REGISTRY:+${BASE_REGISTRY}/}$WORKSPACE_BASE_IMAGE IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE -[ "$ARCH" != "x86_64" ] && export BASE_IMAGE_NAME=$(dirname $BASE_IMAGE_NAME)/$ARCH/$(basename $BASE_IMAGE_NAME) -[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) - - if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then echo echo pulling image: $BASE_IMAGE_NAME @@ -17,7 +13,6 @@ fi docker build --no-cache -f Dockerfile --build-arg BASE_IMAGE_NAME -t $IMAGE_NAME . - echo echo "don't forget to push the image if you wish:" echo "docker push $IMAGE_NAME" diff --git a/image_setup/03_release_image/build.bash b/image_setup/03_release_image/build.bash index 281723c..0a35d4b 100644 --- a/image_setup/03_release_image/build.bash +++ b/image_setup/03_release_image/build.bash @@ -5,14 +5,12 @@ export DATE=$(date) export TAG=$(date +%Y_%m_%d-%H_%M) export HOST=$(hostname) export DEVEL_IMAGE_NAME=${DEVEL_REGISTRY:+${DEVEL_REGISTRY}/}$WORKSPACE_DEVEL_IMAGE -[ "$ARCH" != "x86_64" ] && export DEVEL_IMAGE_NAME=$(dirname $DEVEL_IMAGE_NAME)/$ARCH/$(basename $DEVEL_IMAGE_NAME) #if [ "$DOCKER_REGISTRY_AUTOPULL" = true ]; then #do not pull for release, use the local image, as the release should be based on the exact same devel image #fi IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE -[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) echo "Buidling release image: ${IMAGE_NAME}_$TAG by $USER on $HOST Date: $DATE" docker build --no-cache --build-arg DEVEL_IMAGE_NAME --build-arg USER --build-arg HOST --build-arg DATE -f Dockerfile -t $IMAGE_NAME ../.. diff --git a/image_setup/04_save_release/build.bash b/image_setup/04_save_release/build.bash index 992c5cd..05d384c 100644 --- a/image_setup/04_save_release/build.bash +++ b/image_setup/04_save_release/build.bash @@ -12,7 +12,6 @@ export DATE=$(date +%Y_%m_%d-%H_%M) PROJECT_NAME_NO_SUBFOLDER=${PROJECT_NAME//\//_} IMAGE_NAME=${RELEASE_REGISTRY:+${RELEASE_REGISTRY}/}$WORKSPACE_RELEASE_IMAGE -[ "$ARCH" != "x86_64" ] && IMAGE_NAME=$(dirname $IMAGE_NAME)/$ARCH/$(basename $IMAGE_NAME) SCRIPTFOLDER=${PROJECT_NAME_NO_SUBFOLDER}_scripts_${DATE} mkdir -p $SCRIPTFOLDER @@ -31,5 +30,3 @@ rm -rf $SCRIPTFOLDER echo "saving ${IMAGE_NAME} to ${PROJECT_NAME_NO_SUBFOLDER}_image_${DATE}.tar.gz" docker save ${IMAGE_NAME} | gzip > ${PROJECT_NAME_NO_SUBFOLDER}_image_${DATE}.tar.gz - - diff --git a/settings.bash b/settings.bash index 8f9870a..cbfb398 100755 --- a/settings.bash +++ b/settings.bash @@ -22,20 +22,24 @@ export DEFAULT_EXECMODE="base" # Use this only for setting up the initial devel # export DEFAULT_EXECMODE="devel" # This is used while deveoping code and preparing a relase # export DEFAULT_EXECMODE="release" # use the release as default -### The base image used when building a workspace image (one of the ones build in base_images) -# export WORKSPACE_BASE_IMAGE=developmentimage/rock_master_18.04:base # image with rock core dependencies installed -# export WORKSPACE_BASE_IMAGE=developmentimage/ros_melodic_18.04:base # image with basic ros melodic installed -# export WORKSPACE_BASE_IMAGE=developmentimage/ros_noetic_20.04:base # image with basic ros noetic installed -# export WORKSPACE_BASE_IMAGE=developmentimage/plain_20.04:base # plain image with build_essentials installed -export WORKSPACE_BASE_IMAGE=developmentimage/plain_18.04:base # plain image with build_essentials installed +# set desired processor architecture for image build +# available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 +# default: "" => x86_64 +export ARCH="arm64v8" +### The base image used when building a workspace image (one of the ones build in base_images) +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}rock_master_18.04:base # image with rock core dependencies installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}ros_melodic_18.04:base # image with basic ros melodic installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}ros_noetic_20.04:base # image with basic ros noetic installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}plain_20.04:base # plain image with build_essentials installed +export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}plain_18.04:base # plain image with build_essentials installed # The Name of the Workspace image to use # you should add a workspace name folder and a image name # e.g MY_PROJECT/docker_image_development:devel # under normal circumstances you should not need to change these -export WORKSPACE_DEVEL_IMAGE=developmentimage/${PROJECT_NAME}:devel -export WORKSPACE_RELEASE_IMAGE=developmentimage/${PROJECT_NAME}:release +export WORKSPACE_DEVEL_IMAGE=developmentimage/${ARCH:+$ARCH/}${PROJECT_NAME}:devel +export WORKSPACE_RELEASE_IMAGE=developmentimage/${ARCH:+$ARCH/}${PROJECT_NAME}:release # In case your docker container needs special run paramaters # like open ports, additional mounts etc. @@ -47,9 +51,3 @@ export WORKSPACE_RELEASE_IMAGE=developmentimage/${PROJECT_NAME}:release # --privileged # -v /dev/input/:/dev/input export ADDITIONAL_DOCKER_RUN_ARGS="" - -# set desired processor architecture for image build -# available architectures on docker hub: https://github.com/docker-library/official-images#architectures-other-than-amd64 -# default: x86_64 -# partially supported alternatives: arm32v7, arm64v8 -export ARCH="arm32v7" From f4c0aa6224ec67df4c4becd8470e0e20cb2e74aa Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 18 Jan 2021 11:57:11 +0100 Subject: [PATCH 10/10] Fix ARCH Typo in settings.bash --- settings.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/settings.bash b/settings.bash index cbfb398..eb362c9 100755 --- a/settings.bash +++ b/settings.bash @@ -28,11 +28,11 @@ export DEFAULT_EXECMODE="base" # Use this only for setting up the initial devel export ARCH="arm64v8" ### The base image used when building a workspace image (one of the ones build in base_images) -# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}rock_master_18.04:base # image with rock core dependencies installed -# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}ros_melodic_18.04:base # image with basic ros melodic installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}rock_master_18.04:base # image with rock core dependencies installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}ros_melodic_18.04:base # image with basic ros melodic installed # export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}ros_noetic_20.04:base # image with basic ros noetic installed -# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}plain_20.04:base # plain image with build_essentials installed -export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+ARCH/}plain_18.04:base # plain image with build_essentials installed +# export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}plain_20.04:base # plain image with build_essentials installed +export WORKSPACE_BASE_IMAGE=developmentimage/${ARCH:+$ARCH/}plain_18.04:base # plain image with build_essentials installed # The Name of the Workspace image to use # you should add a workspace name folder and a image name