Skip to content

Commit

Permalink
Fix docker workspace setup for older versions. (StoglRobotics#82)
Browse files Browse the repository at this point in the history
* Add installation possibility for ROS noetic.
  • Loading branch information
destogl authored Nov 17, 2022
1 parent 3dccecb commit 2c4bbd5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 24 deletions.
4 changes: 2 additions & 2 deletions scripts/docker/_RosTeamWs_Docker_Defines.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ source $docker_script_own_dir/../_RosTeamWs_Defines.bash

# assoziative array which maps the chosen rosdistro to the name which is used to install the corresponding
# ros distribution inside docker
declare -r -A map_to_docker_ros_distro_name=( ["foxy"]="foxy" ["galactic"]="galactic" ["rolling"]="rolling" ["humble"]="humble")
declare -r -A ros_distro_to_rtw_branch=( ["foxy"]="foxy" ["galactic"]="master" ["rolling"]="master" ["humble"]="master")
declare -r -A map_to_docker_ros_distro_name=( ["noetic"]="noetic" ["foxy"]="foxy" ["galactic"]="galactic" ["rolling"]="rolling" ["humble"]="humble")
declare -r -A ros_distro_to_rtw_branch=( ["noetic"]="master" ["foxy"]="foxy" ["galactic"]="master" ["rolling"]="master" ["humble"]="master")

# $1 = name (tag) of the created docker image
# $2 = Dockerfile which is used for creating the image
Expand Down
23 changes: 22 additions & 1 deletion scripts/setup-ros-workspace.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source $setup_ws_script_own_dir/docker/_RosTeamWs_Docker_Defines.bash

# All the possible supported ros distributions supported by rtw
if [ -z "$ros_distributions_20_04" ]; then
readonly ros_distributions_20_04=("foxy" "galactic")
readonly ros_distributions_20_04=("noetic" "foxy" "galactic")
fi
if [ -z "$ros_distributions_22_04" ]; then
readonly ros_distributions_22_04=("humble")
Expand Down Expand Up @@ -50,6 +50,8 @@ select_normal_or_nvidia_docker() {
notify_user "To abort press <CTRL>+<C>, to continue press <ENTER>."
read
esac


}

check_user_input () {
Expand Down Expand Up @@ -357,6 +359,25 @@ create_workspace_docker () {
sed -i "s/UBUNTU_DUMMY_VERSION/${ubuntu_version}/g" "$ws_docker_folder/Dockerfile"
sed -i "s/ROS_DUMMY_VERSION/${docker_ros_distro_name}/g" "$ws_docker_folder/Dockerfile"
sed -i "s/ROS_TEAM_WS_DUMMY_BRANCH/${rtw_branch_for_ros_distro}/g" "$ws_docker_folder/Dockerfile"
if [[ "${ubuntu_version}" == *20.04* ]]; then
DOCKER_FILE="$ws_docker_folder/Dockerfile"
TMP_FILE="$ws_docker_folder/.tmp_Dockerfile"
mv $DOCKER_FILE "$TMP_FILE"
TEST_LINE=`awk '$1 == "#" && $2 == "install" && $3 == "nala" { print NR }' $TMP_FILE` # get line before `# install nala and upgrade` dependency
let CUT_LINE=$TEST_LINE-0
head -$CUT_LINE $TMP_FILE > $DOCKER_FILE

echo "RUN apt update -y && apt install -y wget" >> $DOCKER_FILE
echo "RUN echo \"deb [arch=amd64,arm64,armhf] http://deb.volian.org/volian/ scar main\" | tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list" >> $DOCKER_FILE
echo "RUN wget -qO - https://deb.volian.org/volian/scar.key | tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null" >> $DOCKER_FILE
echo "RUN apt update -y && apt install -y nala-legacy" >> $DOCKER_FILE

# Add last part
let CUT_LINE=$TEST_LINE+2
tail -n +$CUT_LINE $TMP_FILE >> $DOCKER_FILE

rm $TMP_FILE
fi

# setup ros_team_ws
cp "$DOCKER_TEMPLATES/ros_team_ws_rc_docker" "$ws_docker_folder/."
Expand Down
32 changes: 20 additions & 12 deletions templates/docker/nvidia.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ ARG home
# make bash default
SHELL ["/bin/bash", "-c"]

# upgrade to newest version
RUN apt-get update -y && apt-get install -y nala
RUN nala upgrade --assume-yes

# install locales
RUN nala install -y locales nala
RUN apt update -y && apt install -y locales

# Configure user env
ENV TZ=Europe/Berlin
Expand All @@ -27,22 +23,34 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Nvidia variables
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

# Make sure UTF-8 is supported
RUN locale

# install nala and upgrade
RUN apt update -y && apt install -y nala
RUN nala upgrade -y

# Nvidia variables
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

# Install basic utilities
RUN nala update && nala install -y git nano sudo tmux tree vim iputils-ping wget bash-completion pre-commit trash-cli gh
RUN nala update && nala install -y git git-lfs nano sudo tmux tree vim iputils-ping wget bash-completion pip trash-cli
RUN pip install pre-commit

# install ROS2:ROS_DUMMY_VERSION dependencies
# install ROS:ROS_DUMMY_VERSION dependencies
RUN nala install -y curl gnupg gnupg2 lsb-release software-properties-common && apt-add-repository universe

# Add key to keyring
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

# ROS repository
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/ros.list > /dev/null

# ROS2 repository
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# install ROS2:ROS_DUMMY_VERSION and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install
RUN nala update && DEBIAN_FRONTEND=noniteractive nala install -y ros-ROS_DUMMY_VERSION-desktop pip python3-colcon-common-extensions python3-vcstool
# install ROS:ROS_DUMMY_VERSION and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install
RUN nala update && DEBIAN_FRONTEND=noniteractive nala install -y ros-ROS_DUMMY_VERSION-desktop python3-colcon-common-extensions python3-vcstool
RUN pip install -U rosdep && \
rosdep init

Expand Down
26 changes: 17 additions & 9 deletions templates/docker/standard.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ ARG home
# make bash default
SHELL ["/bin/bash", "-c"]

# upgrade to newest version
RUN apt-get update -y && apt-get install -y nala
RUN nala upgrade --assume-yes

# install locales
RUN nala install -y locales nala
RUN apt update -y && apt install -y locales

# Configure user env
ENV TZ=Europe/Berlin
Expand All @@ -30,16 +26,28 @@ ENV LC_ALL en_US.UTF-8
# Make sure UTF-8 is supported
RUN locale

# install nala and upgrade
RUN apt update -y && apt install -y nala
RUN nala upgrade -y

# Install basic utilities
RUN nala update && nala install -y git nano sudo tmux tree vim iputils-ping wget bash-completion pre-commit trash-cli gh
RUN nala update && nala install -y git git-lfs nano sudo tmux tree vim iputils-ping wget bash-completion pip trash-cli
RUN pip install pre-commit

# install ROS2:ROS_DUMMY_VERSION dependencies
# install ROS:ROS_DUMMY_VERSION dependencies
RUN nala install -y curl gnupg gnupg2 lsb-release software-properties-common && apt-add-repository universe

# Add key to keyring
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

# ROS repository
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/ros.list > /dev/null

# ROS2 repository
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# install ROS2:ROS_DUMMY_VERSION and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install
RUN nala update && DEBIAN_FRONTEND=noniteractive nala install -y ros-ROS_DUMMY_VERSION-desktop pip python3-colcon-common-extensions python3-vcstool
# install ROS:ROS_DUMMY_VERSION and things needed for ros development, DEBIAN_FRONTEND is needed to ignore interactive keyboard layout setting while install
RUN nala update && DEBIAN_FRONTEND=noniteractive nala install -y ros-ROS_DUMMY_VERSION-desktop python3-colcon-common-extensions python3-vcstool
RUN pip install -U rosdep && \
rosdep init

Expand Down

0 comments on commit 2c4bbd5

Please sign in to comment.