diff --git a/template_ws/docker/Dockerfile b/template_ws/docker/Dockerfile index dee7c69f..5e910fa2 100644 --- a/template_ws/docker/Dockerfile +++ b/template_ws/docker/Dockerfile @@ -1,35 +1,26 @@ # Base Image : https://hub.docker.com/r/osrf/ros/tags?page=1&name=humble FROM osrf/ros:humble-desktop-full +# Arguments for the default user ARG USERNAME=user ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -# Create the user -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && apt-get update \ - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && rm -rf /var/lib/apt/lists/* + +# Upgrade packages +# Ref: https://pythonspeed.com/articles/security-updates-in-docker/ RUN apt-get update && apt-get upgrade -y \ && rm -rf /var/lib/apt/lists/* -RUN apt-get update && apt-get install -y python3-pip \ - && rm -rf /var/lib/apt/lists/* -ENV SHELL /bin/bash -# ******************************************************** -# * Anything else you want to do like clean up goes here * -# ******************************************************** +# Install sudo and create a user with sudo privileges +# Ref: https://stackoverflow.com/a/65434659 +RUN apt-get update && apt-get install -y sudo \ + && useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \ + && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \ + && rm -rf /var/lib/apt/lists/* # Install common tools RUN apt-get update && apt-get install -y \ curl \ git \ - git-extras \ htop \ net-tools \ tmux \ @@ -37,14 +28,24 @@ RUN apt-get update && apt-get install -y \ wget \ && rm -rf /var/lib/apt/lists/* +# Install Python pip +RUN apt-get update && apt-get install -y python3-pip \ + && rm -rf /var/lib/apt/lists/* + +# Install custom tools +RUN apt-get update && apt-get install -y \ + git-extras \ + && rm -rf /var/lib/apt/lists/* + # Install ROS2 RVIZ and Gazebo RUN apt-get update && apt-get install -y \ ros-$ROS_DISTRO-gazebo-ros-pkgs \ ros-$ROS_DISTRO-rviz2 \ && rm -rf /var/lib/apt/lists/* +# TODO: Add more commands here + COPY .bashrc /home/$USERNAME/.bashrc -# [Optional] Set the default user. Omit if you want to keep the default as root. USER $USERNAME CMD ["/bin/bash"]