Skip to content

Commit 89e7188

Browse files
committed
adds a minimal Dockerfile (#91)
1 parent ab5fd15 commit 89e7188

File tree

2 files changed

+33
-58
lines changed

2 files changed

+33
-58
lines changed

Dockerfile

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
FROM nvcr.io/nvidia/pytorch:23.07-py3
1+
FROM nvcr.io/nvidia/pytorch:24.12-py3
22

3-
# Build arguments
4-
ARG USER_ID
5-
ARG GROUP_ID
6-
ARG USER
7-
8-
# Create non-root user: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
9-
RUN groupadd --gid $GROUP_ID $USER \
10-
&& useradd --uid $USER_ID --gid $GROUP_ID -m $USER \
11-
# Add sudo support
12-
&& apt-get update \
3+
# add ubuntu to sudoers: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
4+
RUN apt-get update \
135
&& apt-get install -y sudo \
14-
&& echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \
15-
&& chmod 0440 /etc/sudoers.d/$USER
6+
&& echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
7+
&& chmod 0440 /etc/sudoers.d/ubuntu
168

179
# change default shell
1810
SHELL ["/bin/bash", "-c"]
@@ -21,77 +13,64 @@ SHELL ["/bin/bash", "-c"]
2113
RUN apt-get update && \
2214
apt-get upgrade -y
2315

24-
# install ROS 2 Rolling, see e.g. https://docs.ros.org/en/rolling/Installation/Ubuntu-Install-Debians.html
25-
ARG DEBIAN_FRONTEND=noninteractive
26-
ENV ROS_DISTRO=rolling
16+
# add ROS 2 Jazzy sources, see e.g. https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debians.html
17+
ENV ROS_DISTRO=jazzy
2718
RUN apt-get install software-properties-common -y && \
2819
add-apt-repository universe &&\
2920
apt-get update && apt-get install curl -y && \
3021
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
3122
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 && \
32-
apt-get update && apt-get upgrade -y && \
33-
apt-get install ros-${ROS_DISTRO}-ros-base -y && \
34-
apt-get install ros-dev-tools -y && \
35-
rosdep init
36-
37-
# install some more dependencies
38-
# https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo
39-
RUN apt-get install -y \
40-
libgl1 \
41-
ros-${ROS_DISTRO}-xacro
23+
apt-get update
24+
25+
# install minimal ROS 2 utilities:
26+
# - build: ament_cmake
27+
# - package registry: ament_index_python
28+
# - parse: xacro
29+
# remove ament_cmake_pytest on https://github.com/lbr-stack/lbr_fri_ros2_stack/issues/372
30+
RUN apt-get install python3-colcon-common-extensions \
31+
ros-${ROS_DISTRO}-ament-cmake \
32+
ros-${ROS_DISTRO}-ament-cmake-pytest \
33+
ros-${ROS_DISTRO}-ament-index-python \
34+
ros-${ROS_DISTRO}-xacro -y
4235

4336
# clone the LBR-Stack and xarm source code for robot description only
44-
ENV FRI_CLIENT_VERSION=1.15
4537
RUN mkdir -p ros2_ws/src && \
4638
cd ros2_ws/src && \
4739
git clone https://github.com/lbr-stack/lbr_fri_ros2_stack.git -b $ROS_DISTRO && \
4840
git clone https://github.com/xArm-Developer/xarm_ros2.git --recursive -b $ROS_DISTRO
4941

50-
RUN apt-get install -y \
51-
ros-${ROS_DISTRO}-gazebo-ros \
52-
ros-${ROS_DISTRO}-ros2-control
53-
54-
# copy roboreg for installation (this is done as root...)
42+
# copy roboreg for installation (this is done as root)
5543
COPY . ./roboreg
5644

5745
# change permissions for install
5846
RUN chmod -R 777 roboreg && \
5947
chmod -R 777 ros2_ws
6048

61-
# NON ROOT USER INSTALLATION STUFF...
62-
USER $USER
49+
# non-root user installation stuff (previously for rosdep)
50+
USER ubuntu
6351

6452
# install robot description files (xarm dependencies little intertwined, require some manual installation, done above)
6553
RUN cd ros2_ws && \
6654
source /opt/ros/${ROS_DISTRO}/setup.bash && \
67-
colcon build --symlink-install --packages-select \
68-
xarm_description \
69-
xarm_controller \
70-
xarm_msgs \
71-
xarm_sdk \
72-
xarm_api
73-
RUN cd ros2_ws && \
74-
rosdep update && \
75-
rosdep install --from-paths \
76-
src/lbr_fri_ros2_stack/lbr_description \
77-
-i -r -y --rosdistro=${ROS_DISTRO} && \
78-
source /opt/ros/${ROS_DISTRO}/setup.bash && \
79-
colcon build --symlink-install --packages-select \
80-
lbr_description
55+
colcon build \
56+
--cmake-args -DBUILD_TESTING=0 \
57+
--packages-select \
58+
xarm_description \
59+
lbr_description
8160

8261
# source ROS 2 workspace
83-
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USER/.bashrc && \
84-
echo "source /workspace/ros2_ws/install/local_setup.bash" >> /home/$USER/.bashrc
62+
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/ubuntu/.bashrc && \
63+
echo "source /workspace/ros2_ws/install/local_setup.bash" >> /home/ubuntu/.bashrc
8564

8665
# extend PYTHONPATH and PATH (for CLI)
87-
ENV PYTHONPATH="/home/$USER/.local/lib/python3.10/site-packages"
88-
ENV PATH="$PATH:/home/$USER/.local/bin"
66+
ENV PYTHONPATH="/home/ubuntu/.local/lib/python3.12/site-packages"
67+
ENV PATH="$PATH:/home/ubuntu/.local/bin"
8968

9069
# install roboreg
9170
RUN pip3 install roboreg/
9271

9372
# limit concurrent compilation for ninja, refer https://github.com/NVlabs/nvdiffrast/issues/201
94-
ENV MAX_JOBS=1
73+
ENV MAX_JOBS=2
9574

9675
# run inside the roboreg folder (where data is located)
9776
WORKDIR /workspace/roboreg

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ Next:
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 . --tag roboreg
9793
```
9894

9995
3. Run container

0 commit comments

Comments
 (0)