|
| 1 | +FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 AS builder |
| 2 | + |
| 3 | +# create ubuntu user |
| 4 | +RUN groupadd --gid 1000 ubuntu \ |
| 5 | + && useradd --uid 1000 --gid 1000 -m ubuntu |
| 6 | + |
| 7 | +# add ROS 2 Jazzy sources, see e.g. https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debians.html |
| 8 | +ENV DEBIAN_FRONTEND=noninteractive |
| 9 | +ENV ROS_DISTRO=humble |
| 10 | +RUN apt-get update && \ |
| 11 | + apt-get install software-properties-common -y && \ |
| 12 | + add-apt-repository universe &&\ |
| 13 | + apt-get update && apt-get install curl -y && \ |
| 14 | + curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \ |
| 15 | + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \ |
| 16 | + apt-get update |
| 17 | + |
| 18 | +# install build tools (unavailable in base image and only required for builder stage) |
| 19 | +RUN apt-get install \ |
| 20 | + git \ |
| 21 | + cmake \ |
| 22 | + python3 \ |
| 23 | + python3-venv \ |
| 24 | + python3-pip -y |
| 25 | + |
| 26 | +# install minimal ROS 2 build utilities |
| 27 | +# remove ament_cmake_pytest on https://github.com/lbr-stack/lbr_fri_ros2_stack/issues/372 |
| 28 | +RUN apt-get install \ |
| 29 | + python3-colcon-common-extensions \ |
| 30 | + ros-${ROS_DISTRO}-ament-cmake \ |
| 31 | + ros-${ROS_DISTRO}-ament-cmake-pytest -y |
| 32 | + |
| 33 | +# clone the LBR-Stack and xarm source code for robot description only |
| 34 | +WORKDIR /home/ubuntu |
| 35 | +RUN mkdir -p roboreg-deployment/src && \ |
| 36 | + cd roboreg-deployment/src && \ |
| 37 | + git clone https://github.com/lbr-stack/lbr_fri_ros2_stack.git -b $ROS_DISTRO && \ |
| 38 | + git clone https://github.com/xArm-Developer/xarm_ros2.git --recursive -b $ROS_DISTRO |
| 39 | + |
| 40 | +# copy roboreg for installation (this is done as root) |
| 41 | +COPY . ./roboreg |
| 42 | + |
| 43 | +# change permissions for install |
| 44 | +RUN chmod -R 777 \ |
| 45 | + roboreg-deployment \ |
| 46 | + roboreg |
| 47 | + |
| 48 | +# non-root user installation stuff |
| 49 | +USER ubuntu |
| 50 | + |
| 51 | +# create a virtual environment |
| 52 | +RUN cd roboreg-deployment && \ |
| 53 | + python3 -m venv roboreg-venv && \ |
| 54 | + touch roboreg-venv/COLCON_IGNORE |
| 55 | + |
| 56 | +# change default shell |
| 57 | +SHELL ["/bin/bash", "-c"] |
| 58 | + |
| 59 | +# install roboreg into the venv |
| 60 | +RUN source roboreg-deployment/roboreg-venv/bin/activate && \ |
| 61 | + pip3 install roboreg/ |
| 62 | + |
| 63 | +# install robot description files (xarm dependencies little intertwined, require some manual installation, done above) |
| 64 | +RUN cd roboreg-deployment && \ |
| 65 | + source /opt/ros/${ROS_DISTRO}/setup.bash && \ |
| 66 | + colcon build \ |
| 67 | + --cmake-args -DBUILD_TESTING=0 \ |
| 68 | + --packages-select \ |
| 69 | + xarm_description \ |
| 70 | + lbr_description |
| 71 | + |
| 72 | +FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 |
| 73 | + |
| 74 | +# create ubuntu user |
| 75 | +RUN groupadd --gid 1000 ubuntu \ |
| 76 | + && useradd --uid 1000 --gid 1000 -m ubuntu \ |
| 77 | + && apt-get update \ |
| 78 | + && apt-get install -y sudo \ |
| 79 | + && echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \ |
| 80 | + && chmod 0440 /etc/sudoers.d/ubuntu |
| 81 | + |
| 82 | +# add ROS 2 Jazzy sources, see e.g. https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debians.html |
| 83 | +ENV DEBIAN_FRONTEND=noninteractive |
| 84 | +ENV ROS_DISTRO=humble |
| 85 | +RUN apt-get update && \ |
| 86 | + apt-get install software-properties-common -y && \ |
| 87 | + add-apt-repository universe &&\ |
| 88 | + apt-get update && apt-get install curl -y && \ |
| 89 | + curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \ |
| 90 | + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \ |
| 91 | + apt-get update |
| 92 | + |
| 93 | +# install minimal runtime utilities |
| 94 | +RUN apt-get install \ |
| 95 | + python3 \ |
| 96 | + python3-setuptools \ |
| 97 | + ros-${ROS_DISTRO}-ament-index-python \ |
| 98 | + ros-${ROS_DISTRO}-xacro \ |
| 99 | + libgl1 \ |
| 100 | + libxrender1 -y |
| 101 | + |
| 102 | +# change default shell (for ROS sourcing) |
| 103 | +SHELL ["/bin/bash", "-c"] |
| 104 | + |
| 105 | +# non-root user |
| 106 | +USER ubuntu |
| 107 | +WORKDIR /home/ubuntu |
| 108 | + |
| 109 | +# copy roboreg-deployment from builder stage |
| 110 | +COPY --from=builder /home/ubuntu/roboreg-deployment/roboreg-venv /home/ubuntu/roboreg-deployment/roboreg-venv |
| 111 | +COPY --from=builder /home/ubuntu/roboreg-deployment/install /home/ubuntu/roboreg-deployment/install |
| 112 | +COPY --from=builder /home/ubuntu/roboreg/test/assets /home/ubuntu/sample-data |
| 113 | + |
| 114 | +# source ROS 2 workspace |
| 115 | +RUN echo "source /home/ubuntu/roboreg-deployment/install/setup.bash" >> /home/ubuntu/.bashrc |
| 116 | +RUN echo "source /home/ubuntu/roboreg-deployment/roboreg-venv/bin/activate" >> /home/ubuntu/.bashrc |
| 117 | + |
| 118 | +# extend PATH (for CLI) |
| 119 | +ENV PATH="$PATH:/home/ubuntu/roboreg-deployment/roboreg-venv/bin" |
| 120 | + |
| 121 | +# run inside the roboreg folder (where data is located) |
| 122 | +CMD ["/bin/bash"] |
0 commit comments