From ced462fbb36298fd02b6f905fd31b728f1fd5717 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Fri, 1 Nov 2024 12:17:33 +0800 Subject: [PATCH] feat: Fix file copy ownership --- aloha_ws/docker/Dockerfile | 10 ++++++---- cartographer_ws/docker/Dockerfile | 5 +++-- gazebo_world_ws/docker/Dockerfile | 5 +++-- husky_ws/docker/Dockerfile | 14 +++++++++----- kobuki_ws/docker/Dockerfile | 11 +++++++---- orbslam3_ws/docker/Dockerfile | 5 +++-- ros1_bridge_ws/docker/Dockerfile | 12 +++++++----- rtabmap_ws/docker/Dockerfile | 5 +++-- template_ws/docker/Dockerfile | 5 +++-- tests/diff_base/docker/Dockerfile | 5 +++-- vlp_ws/docker/Dockerfile | 5 +++-- 11 files changed, 50 insertions(+), 32 deletions(-) diff --git a/aloha_ws/docker/Dockerfile b/aloha_ws/docker/Dockerfile index e44fa180..19c626fb 100644 --- a/aloha_ws/docker/Dockerfile +++ b/aloha_ws/docker/Dockerfile @@ -114,7 +114,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -138,7 +138,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ # Install Aloha Interbotix dependencies # Ref: https://docs.trossenrobotics.com/interbotix_xsarms_docs/ros_interface/ros2/software_setup.html#amd64-architecture # Ref: https://github.com/Interbotix/interbotix_ros_manipulators/blob/humble/interbotix_ros_xsarms/install/amd64/xsarm_amd64_install.sh -# Install ros packages based on Interbotix rosdeps +# Install ros packages based on Interbotix rosdeps to speed up build RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ sudo apt-get update && sudo apt-get install -y \ ros-$ROS_DISTRO-moveit-msgs \ @@ -165,14 +165,16 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-joint-state-publisher-gui \ ros-$ROS_DISTRO-topic-based-ros2-control \ && sudo rm -rf /var/lib/apt/lists/* -COPY script/xsarm_amd64_install.sh /home/user +COPY --chown=$USERNAME:$USERNAME \ + script/xsarm_amd64_install.sh /home/$USERNAME RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ bash -ie ~/xsarm_amd64_install.sh -d humble -n \ && sudo rm -rf /var/lib/apt/lists/* \ && rm -rf $HOME/.ros/rosdep/sources.cache COPY udev_rules/99-interbotix-udev.rules /etc/udev/rules.d/ -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/cartographer_ws/docker/Dockerfile b/cartographer_ws/docker/Dockerfile index d44c4769..bc7a625a 100644 --- a/cartographer_ws/docker/Dockerfile +++ b/cartographer_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -137,7 +137,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-rqt-robot-steering \ && sudo rm -rf /var/lib/apt/lists/* -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/gazebo_world_ws/docker/Dockerfile b/gazebo_world_ws/docker/Dockerfile index d9ec7dde..8b662bfc 100644 --- a/gazebo_world_ws/docker/Dockerfile +++ b/gazebo_world_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -130,7 +130,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ && sudo rm -rf /var/lib/apt/lists/* # TODO: Add more commands here -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/husky_ws/docker/Dockerfile b/husky_ws/docker/Dockerfile index 148eea28..bc17b319 100644 --- a/husky_ws/docker/Dockerfile +++ b/husky_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -157,25 +157,29 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-imu-tools \ ros-$ROS_DISTRO-teleop-twist-keyboard \ && sudo rm -rf /var/lib/apt/lists/* -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here # Setup husky controller by the script. # Build certain packages from source for arm64. -COPY script /home/$USERNAME/script +COPY --chown=$USERNAME:$USERNAME \ + script /home/$USERNAME/script RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ sudo apt-get update \ && bash -ie /home/$USERNAME/script/install-clearpath-robot.sh \ && sudo rm -rf /var/lib/apt/lists/* # Note: The script need to be run as user, not root. # Reference: https://github.com/clearpathrobotics/clearpath_computer_installer/tree/main -COPY clearpath_computer_installer /home/$USERNAME/clearpath_computer_installer +COPY --chown=$USERNAME:$USERNAME \ + clearpath_computer_installer /home/$USERNAME/clearpath_computer_installer RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ sudo apt-get update \ && bash -ie /home/$USERNAME/clearpath_computer_installer/clearpath_computer_installer.sh \ && sudo rm -rf /var/lib/apt/lists/* # Setup udev rules. -COPY udev_rules /home/$USERNAME/udev_rules +COPY --chown=$USERNAME:$USERNAME \ + udev_rules /home/$USERNAME/udev_rules RUN /home/$USERNAME/udev_rules/install_udev_rules.sh # Generate robot configuration files. RUN bash -ie /home/$USERNAME/script/husky-generate.sh diff --git a/kobuki_ws/docker/Dockerfile b/kobuki_ws/docker/Dockerfile index 4a1b1784..a5a95fcd 100644 --- a/kobuki_ws/docker/Dockerfile +++ b/kobuki_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -166,15 +166,18 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-slam-toolbox \ ros-$ROS_DISTRO-robot-localization \ && sudo rm -rf /var/lib/apt/lists/* -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here # Setup udev rules for Kobuki. -COPY udev_rules /home/$USERNAME/udev_rules +COPY --chown=$USERNAME:$USERNAME \ + udev_rules /home/$USERNAME/udev_rules RUN /home/$USERNAME/udev_rules/install_udev_rules.sh # Build the kobuki driver workspace -COPY --chown=$USER_UID kobuki_driver_ws /home/$USERNAME/kobuki_driver_ws +COPY --chown=$USERNAME:$USERNAME \ + kobuki_driver_ws /home/$USERNAME/kobuki_driver_ws RUN cd /home/$USERNAME/kobuki_driver_ws \ && rm -rf COLCON_IGNORE \ && /bin/bash -c "source /opt/ros/$ROS_DISTRO/setup.bash; colcon build --symlink-install" diff --git a/orbslam3_ws/docker/Dockerfile b/orbslam3_ws/docker/Dockerfile index b0aaec1b..ea9a4d95 100644 --- a/orbslam3_ws/docker/Dockerfile +++ b/orbslam3_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -194,7 +194,8 @@ RUN rosdep update && \ . /opt/ros/humble/setup.sh && \ colcon build --symlink-install --packages-select orbslam3 -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/ros1_bridge_ws/docker/Dockerfile b/ros1_bridge_ws/docker/Dockerfile index b781e255..21f54d65 100644 --- a/ros1_bridge_ws/docker/Dockerfile +++ b/ros1_bridge_ws/docker/Dockerfile @@ -40,7 +40,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ################################################################################################ # - Build stage # - In this stage, I will build ROS Humble and ros1-bridge from source. -# - Reference: +# - Reference: # - https://docs.ros.org/en/humble/How-To-Guides/Using-ros1_bridge-Jammy-upstream.html # - https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html ################################################################################################ @@ -126,7 +126,7 @@ RUN colcon build # Delete packages.ros.org from sources.list and remove conflicts packages manually. # Removing those conflicts packages is necessary for install ros-core-dev. # Here is the dicussion about this issue: https://github.com/j3soon/ros2-essentials/pull/9#discussion_r1375303858 -# Reference: +# Reference: # - https://docs.ros.org/en/humble/How-To-Guides/Using-ros1_bridge-Jammy-upstream.html#ros-2-via-debian-packages # - https://github.com/osrf/docker_images/issues/635#issuecomment-1217505552 RUN rm -rf /etc/apt/sources.list.d/ros2.list \ @@ -149,7 +149,8 @@ RUN source install/setup.bash \ # Other configurations USER $USERNAME -COPY ./start-bridge.sh /start-bridge.sh +COPY --chown=$USERNAME:$USERNAME \ + ./start-bridge.sh /start-bridge.sh ENTRYPOINT [] CMD ["/bin/bash"] @@ -169,7 +170,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ tzdata \ && rm -rf /var/lib/apt/lists/* -# Install ROS core and packages with their dependencies. +# Install ROS core and packages with their dependencies. RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ apt-get update && apt-get install -y \ ros-core-dev \ @@ -182,6 +183,7 @@ COPY --from=build /ros2_humble/install /ros2_humble/install # Other configurations USER $USERNAME -COPY ./start-bridge.sh /start-bridge.sh +COPY --chown=$USERNAME:$USERNAME \ + ./start-bridge.sh /start-bridge.sh ENTRYPOINT [] CMD ["./start-bridge.sh"] \ No newline at end of file diff --git a/rtabmap_ws/docker/Dockerfile b/rtabmap_ws/docker/Dockerfile index 8508a7f9..69790efd 100644 --- a/rtabmap_ws/docker/Dockerfile +++ b/rtabmap_ws/docker/Dockerfile @@ -119,7 +119,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -142,7 +142,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-rtabmap-ros \ && sudo rm -rf /var/lib/apt/lists/* -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/template_ws/docker/Dockerfile b/template_ws/docker/Dockerfile index ce2f44ac..14441e26 100644 --- a/template_ws/docker/Dockerfile +++ b/template_ws/docker/Dockerfile @@ -114,7 +114,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -128,7 +128,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ && sudo rm -rf /var/lib/apt/lists/* # TODO: Add more commands here -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"] diff --git a/tests/diff_base/docker/Dockerfile b/tests/diff_base/docker/Dockerfile index 3a6890ec..083d021d 100644 --- a/tests/diff_base/docker/Dockerfile +++ b/tests/diff_base/docker/Dockerfile @@ -114,7 +114,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -129,7 +129,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ # TODO: Add more commands here {PLACEHOLDER_MULTILINE} -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here {PLACEHOLDER_MULTILINE} ENTRYPOINT [] diff --git a/vlp_ws/docker/Dockerfile b/vlp_ws/docker/Dockerfile index cec505a8..76272711 100644 --- a/vlp_ws/docker/Dockerfile +++ b/vlp_ws/docker/Dockerfile @@ -116,7 +116,7 @@ RUN mkdir /home/$USERNAME/.gazebo # Note that installing Isaac Sim with pip is experimental, keep this in mind when unexpected error occurs # TODO: Remove the note above when it is no longer experimental # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_python.html#installation-using-pip -RUN --mount=type=cache,target=/home/user/.cache/pip,sharing=private \ +RUN --mount=type=cache,target=/home/$USERNAME/.cache/pip,sharing=private \ if [ "$TARGETARCH" = "amd64" ]; then \ python3 -V | grep "Python 3.10" \ && pip install isaacsim==4.2.0.2 --extra-index-url https://pypi.nvidia.com \ @@ -149,7 +149,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private \ ros-$ROS_DISTRO-velodyne \ && sudo rm -rf /var/lib/apt/lists/* -COPY .bashrc /home/$USERNAME/.bashrc +COPY --chown=$USERNAME:$USERNAME \ + .bashrc /home/$USERNAME/.bashrc # TODO: Copy additional files here ENTRYPOINT [] CMD ["/bin/bash"]