diff --git a/Makefile b/Makefile index 0884e71..7b39daa 100755 --- a/Makefile +++ b/Makefile @@ -169,6 +169,12 @@ cpu_ros_melodic: ## [CPU] Build ROS Melodic Container docker build -t turlucode/ros-melodic:cpu cpu/melodic/base @printf "\n\033[92mDocker Image: turlucode/ros-melodic:cpu\033[0m\n" +## NOETIC + +cpu_ros_noetic: ## [CPU] Build ROS Noetic Container + docker build -t turlucode/ros-noetic:cpu cpu/noetic/base + @printf "\n\033[92mDocker Image: turlucode/ros-noetic:cpu\033[0m\n" + ## Helper TASKS cpu_run_help: ## [CPU] Prints help and hints on how to run an [CPU]-based image @printf "\nCommand example:\ndocker run --rm -it --runtime=nvidia --privileged --net=host --ipc=host \\ \n--device=/dev/dri:/dev/dri \\ \n-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY \\ \n-v $HOME/.Xauthority:/root/.Xauthority -e XAUTHORITY=/root/.Xauthority \\ \n-v :/root/catkin_ws \\ \n-e ROS_IP= \\ \nturlucode/ros-indigo:cpu\n" diff --git a/Readme.md b/Readme.md index 9c266e4..bff7091 100644 --- a/Readme.md +++ b/Readme.md @@ -29,7 +29,8 @@ Support for other grahics cards will follow! | Indigo | yes | - CUDA 8 (cuDNN 6,7)
- CUDA 10 (cuDNN 7)
- CUDA 10.1 (cuDNN 7) | - OpenCV 2.x (default)
- OpenCV 3.x | | Kinetic | yes | - CUDA 8 (cuDNN 6)
- CUDA 10 (cuDNN 7)
- CUDA 10.1 (cuDNN 7) | - OpenCV 2.x (default)
- OpenCV 3.x | | Melodic | yes | - CUDA 10 (cuDNN 7)
- CUDA 10.1 (cuDNN 7) | - OpenCV 3.x (default) | -| Bouncy (ROS2) | yes | no support yet | - OpenCV 3.x (default) | +| Noetic | yes | coming soon! | - OpenCV 4.x (default) | +| Bouncy (ROS2) | yes | no support yet | - OpenCV 3.x (Ubuntu 18.04) | You can also see the complete list by running: @@ -59,7 +60,7 @@ docker run --rm -it --privileged --net=host --ipc=host \ --device=/dev/dri:/dev/dri \ -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY \ -v $HOME/.Xauthority:/home/$(id -un)/.Xauthority -e XAUTHORITY=/home/$(id -un)/.Xauthority \ --e ROS_IP=localhost \ +-e ROS_IP=127.0.0.1 \ turlucode/ros-indigo:cpu ```` A terminator window will pop-up and the rest you know it! :) @@ -79,7 +80,7 @@ docker run --rm -it --privileged --net=host --ipc=host \ -e DOCKER_USER_ID=$(id -u) \ -e DOCKER_USER_GROUP_NAME=$(id -gn) \ -e DOCKER_USER_GROUP_ID=$(id -g) \ --e ROS_IP=localhost \ +-e ROS_IP=127.0.0.1 \ turlucode/ros-indigo:cpu ```` @@ -213,7 +214,7 @@ docker run --rm -it --runtime=nvidia --privileged --net=host --ipc=host \ -e DOCKER_USER_ID=$(id -u) \ -e DOCKER_USER_GROUP_NAME=$(id -gn) \ -e DOCKER_USER_GROUP_ID=$(id -g) \ --e ROS_IP=localhost \ +-e ROS_IP=127.0.0.1 \ turlucode/ros-indigo:nvidia ```` diff --git a/cpu/noetic/base/Dockerfile b/cpu/noetic/base/Dockerfile new file mode 100644 index 0000000..52f2903 --- /dev/null +++ b/cpu/noetic/base/Dockerfile @@ -0,0 +1,87 @@ +FROM ubuntu:20.04 + +MAINTAINER Athanasios Tasoglou +LABEL Description="ROS-Melodic-Desktop (Ubuntu 20.04)" Vendor="TurluCode" Version="1.0" +LABEL com.turlucode.ros.version="noetic" + +# Install packages without prompting the user to answer any questions +ENV DEBIAN_FRONTEND noninteractive + +# Install packages +RUN apt-get update && apt-get install -y \ +locales \ +lsb-release \ +mesa-utils \ +git \ +subversion \ +nano \ +terminator \ +xterm \ +wget \ +curl \ +htop \ +libssl-dev \ +build-essential \ +dbus-x11 \ +software-properties-common \ +gdb valgrind && \ +apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install cmake 3.17.3 +RUN git clone https://github.com/Kitware/CMake.git && \ +cd CMake && git checkout tags/v3.17.3 && ./bootstrap --parallel=8 && make -j8 && make install && \ +cd .. && rm -rf CMake + +# Install new paramiko (solves ssh issues) +RUN apt-add-repository universe +RUN apt-get update && apt-get install -y python3-pip python build-essential && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN /usr/bin/yes | pip3 install --upgrade pip +RUN /usr/bin/yes | pip3 install --upgrade virtualenv +RUN /usr/bin/yes | pip3 install --upgrade paramiko +RUN /usr/bin/yes | pip3 install --ignore-installed --upgrade numpy protobuf +RUN /usr/bin/yes | pip3 install --upgrade setuptools + +# Locale +RUN locale-gen en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# Install OhMyZSH +RUN apt-get update && apt-get install -y zsh && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true +RUN chsh -s /usr/bin/zsh root +RUN git clone https://github.com/sindresorhus/pure /root/.oh-my-zsh/custom/pure +RUN ln -s /root/.oh-my-zsh/custom/pure/pure.zsh-theme /root/.oh-my-zsh/custom/ +RUN ln -s /root/.oh-my-zsh/custom/pure/async.zsh /root/.oh-my-zsh/custom/ +RUN sed -i -e 's/robbyrussell/refined/g' /root/.zshrc + +# Terminator Config +RUN mkdir -p /root/.config/terminator/ +COPY assets/terminator_config /root/.config/terminator/config +COPY assets/terminator_background.png /root/.config/terminator/background.png + +# Install ROS +RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' +RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 +RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \ +libpcap-dev \ +gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \ +ros-noetic-desktop-full python3-rosdep python3-rosinstall-generator python3-vcstool build-essential \ +ros-noetic-socketcan-bridge \ +ros-noetic-geodesy && \ +apt-get clean && rm -rf /var/lib/apt/lists/* + +# Configure ROS +RUN rosdep init && rosdep update +RUN echo "source /opt/ros/noetic/setup.bash" >> /root/.bashrc +RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> /root/.bashrc +RUN echo "source /opt/ros/noetic/setup.zsh" >> /root/.zshrc +RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> /root/.zshrc + +# Entry script - This will also run terminator +COPY assets/entrypoint_setup.sh / +ENTRYPOINT ["/entrypoint_setup.sh"] + +# --- +CMD ["terminator"] \ No newline at end of file diff --git a/cpu/noetic/base/assets/entrypoint_setup.sh b/cpu/noetic/base/assets/entrypoint_setup.sh new file mode 100755 index 0000000..28d0734 --- /dev/null +++ b/cpu/noetic/base/assets/entrypoint_setup.sh @@ -0,0 +1,119 @@ +#! /bin/bash + +# Functions +# TOOD: Check if we can use: getent passwd $USER to extract all variables +# TODO: Check for valid inputs, cause now it will go through even with bad inputs +check_envs () { + DOCKER_CUSTOM_USER_OK=true; + if [ -z ${DOCKER_USER_NAME+x} ]; then + DOCKER_CUSTOM_USER_OK=false; + return; + fi + + if [ -z ${DOCKER_USER_ID+x} ]; then + DOCKER_CUSTOM_USER_OK=false; + return; + else + if ! [ -z "${DOCKER_USER_ID##[0-9]*}" ]; then + echo -e "\033[1;33mWarning: User-ID should be a number. Falling back to defaults.\033[0m" + DOCKER_CUSTOM_USER_OK=false; + return; + fi + fi + + if [ -z ${DOCKER_USER_GROUP_NAME+x} ]; then + DOCKER_CUSTOM_USER_OK=false; + return; + fi + + if [ -z ${DOCKER_USER_GROUP_ID+x} ]; then + DOCKER_CUSTOM_USER_OK=false; + return; + else + if ! [ -z "${DOCKER_USER_GROUP_ID##[0-9]*}" ]; then + echo -e "\033[1;33mWarning: Group-ID should be a number. Falling back to defaults.\033[0m" + DOCKER_CUSTOM_USER_OK=false; + return; + fi + fi +} + +setup_env_user () { + USER=$1 + USER_ID=$2 + GROUP=$3 + GROUP_ID=$4 + + ## Create user + useradd -m $USER + + ## Copy zsh/sh configs + cp /root/.profile /home/$USER/ + cp /root/.bashrc /home/$USER/ + cp /root/.zshrc /home/$USER/ + ## Copy terminator configs + mkdir -p /home/$USER/.config/terminator + cp /root/.config/terminator/config /home/$USER/.config/terminator/config + cp /root/.config/terminator/background.png /home/$USER/.config/terminator/background.png + cp -rf /root/.oh-my-zsh /home/$USER/ + rm -rf /home/$USER/.oh-my-zsh/custom/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/async.zsh + ln -s /home/$USER/.oh-my-zsh/custom/pure/pure.zsh-theme /home/$USER/.oh-my-zsh/custom/ + ln -s /home/$USER/.oh-my-zsh/custom/pure/async.zsh /home/$USER/.oh-my-zsh/custom/ + sed -i -e 's@ZSH=\"/root@ZSH=\"/home/$USER@g' /home/$USER/.zshrc + # Copy SSH keys & fix owner + if [ -d "/root/.ssh" ]; then + cp -rf /root/.ssh /home/$USER/ + chown -R $USER:$GROUP /home/$USER/.ssh + fi + + ## Fix owner + chown $USER:$GROUP /home/$USER + chown -R $USER:$GROUP /home/$USER/.config + chown $USER:$GROUP /home/$USER/.profile + chown $USER:$GROUP /home/$USER/.bashrc + chown $USER:$GROUP /home/$USER/.zshrc + chown -R $USER:$GROUP /home/$USER/.oh-my-zsh + + ## This a trick to keep the evnironmental variables of root which is important! + echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.bashrc + echo " cd /home/$DOCKER_USER_NAME" >> /root/.bashrc + echo " su $DOCKER_USER_NAME" >> /root/.bashrc + echo "fi" >> /root/.bashrc + + echo "if ! [ \"$DOCKER_USER_NAME\" = \"$(id -un)\" ]; then" >> /root/.zshrc + echo " cd /home/$DOCKER_USER_NAME" >> /root/.zshrc + echo " su $DOCKER_USER_NAME" >> /root/.zshrc + echo "fi" >> /root/.zshrc + + ## Setup Password-file + PASSWDCONTENTS=$(grep -v "^${USER}:" /etc/passwd) + GROUPCONTENTS=$(grep -v -e "^${GROUP}:" -e "^docker:" /etc/group) + + (echo "${PASSWDCONTENTS}" && echo "${USER}:x:$USER_ID:$GROUP_ID::/home/$USER:/bin/bash") > /etc/passwd + (echo "${GROUPCONTENTS}" && echo "${GROUP}:x:${GROUP_ID}:") > /etc/group + (if test -f /etc/sudoers ; then echo "${USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ; fi) +} + + +# ---Main--- + +# Create new user +## Check Inputs +check_envs + +## Determine user & Setup Environment +if [ $DOCKER_CUSTOM_USER_OK == true ]; then + echo " -->DOCKER_USER Input is set to '$DOCKER_USER_NAME:$DOCKER_USER_ID:$DOCKER_USER_GROUP_NAME:$DOCKER_USER_GROUP_ID'"; + echo -e "\033[0;32mSetting up environment for user=$DOCKER_USER_NAME\033[0m" + setup_env_user $DOCKER_USER_NAME $DOCKER_USER_ID $DOCKER_USER_GROUP_NAME $DOCKER_USER_GROUP_ID +else + echo " -->DOCKER_USER* variables not set. Using 'root'."; + echo -e "\033[0;32mSetting up environment for user=root\033[0m" + DOCKER_USER_NAME="root" +fi + +# Change shell to zsh +chsh -s /usr/bin/zsh $DOCKER_USER_NAME + +# Run CMD from Docker +"$@" \ No newline at end of file diff --git a/cpu/noetic/base/assets/terminator_background.png b/cpu/noetic/base/assets/terminator_background.png new file mode 100644 index 0000000..e637f1c Binary files /dev/null and b/cpu/noetic/base/assets/terminator_background.png differ diff --git a/cpu/noetic/base/assets/terminator_config b/cpu/noetic/base/assets/terminator_config new file mode 100644 index 0000000..18df2fb --- /dev/null +++ b/cpu/noetic/base/assets/terminator_config @@ -0,0 +1,23 @@ +[global_config] + title_receive_bg_color = "#64d8ff" + enabled_plugins = TerminalShot, LaunchpadCodeURLHandler, APTURLHandler, Logger, LaunchpadBugURLHandler + title_transmit_bg_color = "#15b0dc" +[keybindings] +[profiles] + [[default]] + use_system_font = False + background_darkness = 0.69 + background_type = transparent + background_image = /root/.config/terminator/background.png + scroll_background = False + font = Monospace 12 + scrollback_infinite = True +[layouts] + [[default]] + [[[child1]]] + type = Terminal + parent = window0 + [[[window0]]] + type = Window + parent = "" +[plugins]