Skip to content

Commit 2df5f4a

Browse files
authored
Merge pull request #96 from lbr-stack/fix/roboreg-91/docker
minimal docker (#91)
2 parents efde9bc + 925b454 commit 2df5f4a

File tree

4 files changed

+241
-108
lines changed

4 files changed

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

Dockerfile

Lines changed: 0 additions & 98 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,16 @@ Next:
8585
git clone git@github.com:lbr-stack/roboreg.git
8686
```
8787

88-
2. Build the Docker image
88+
2. Build the Docker image (currently only runtime support, i.e. no rendering via compiled kernels)
8989

9090
```shell
9191
cd roboreg
92-
docker build . \
93-
--tag roboreg \
94-
--build-arg USER_ID=$(id -u) \
95-
--build-arg GROUP_ID=$(id -g) \
96-
--build-arg USER=$USER
92+
docker build -t roboreg:cuda-13.1.0-runtime-ubuntu-24.04 -f .docker/cuda-13.1.0-runtime-ubuntu-24.04.Dockerfile .
9793
```
9894

99-
3. Run container
95+
3. Run container (on Linux host with [NVIDIA Container Toolkit](#docker-comes-with-cuda-toolkit))
10096

10197
```shell
102-
docker remove roboreg-container
10398
docker run -it \
10499
--gpus all \
105100
--network host \
@@ -109,8 +104,7 @@ Next:
109104
--volume /dev:/dev --privileged \
110105
--env DISPLAY \
111106
--env QT_X11_NO_MITSHM=1 \
112-
--name roboreg-container \
113-
roboreg
107+
roboreg:cuda-13.1.0-runtime-ubuntu-24.04
114108
```
115109

116110
## Command Line Interface

0 commit comments

Comments
 (0)