Skip to content

Commit 5d414fa

Browse files
committed
removed ROS from docker (#110)
1 parent 87235ed commit 5d414fa

File tree

3 files changed

+60
-152
lines changed

3 files changed

+60
-152
lines changed

.docker/Dockerfile

Lines changed: 40 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,46 @@
11
# Build arguments for version configuration
2-
ARG UBUNTU_VERSION=24.04
3-
ARG CUDA_VERSION=13.1.0
4-
ARG ROS_DISTRO=jazzy
2+
ARG PYTORCH_VERSION=2.10.0
3+
ARG CUDA_VERSION=12.6
54

6-
FROM ubuntu:${UBUNTU_VERSION} AS builder
7-
8-
# Re-declare ARG after FROM to make it available in this stage
9-
ARG ROS_DISTRO
10-
ARG UBUNTU_VERSION
5+
FROM pytorch/pytorch:${PYTORCH_VERSION}-cuda${CUDA_VERSION}-cudnn9-runtime
116

127
# setup
138
ENV DEBIAN_FRONTEND=noninteractive
14-
ENV ROS_DISTRO=${ROS_DISTRO}
159

16-
# install build dependencies
17-
RUN apt-get update \
18-
# add ROS 2 sources, see e.g. https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
19-
&& apt-get install -y \
20-
software-properties-common \
21-
&& add-apt-repository universe \
22-
&& apt-get update \
23-
&& apt-get install -y \
24-
curl \
25-
&& curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
26-
&& 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 \
10+
# create ubuntu user only if it doesn't exist yet
11+
RUN getent group ubuntu || groupadd --gid 1000 ubuntu \
12+
&& id -u ubuntu >/dev/null 2>&1 || useradd --uid 1000 --gid 1000 -m ubuntu \
13+
# add ubuntu to sudoers: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
2714
&& apt-get update \
15+
&& apt-get install -y sudo \
16+
&& echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
17+
&& chmod 0440 /etc/sudoers.d/ubuntu \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# install dependencies (most for displaying, can be removed if not needed)
21+
RUN apt-get update \
2822
# install build tools (unavailable in base image and only required for builder stage)
2923
&& apt-get install -y \
30-
git \
31-
cmake \
32-
python3 \
33-
python3-venv \
34-
python3-pip \
35-
# install minimal ROS 2 build utilities
36-
# remove ament_cmake_pytest on https://github.com/lbr-stack/lbr_fri_ros2_stack/issues/372
37-
&& apt-get install -y \
38-
python3-colcon-common-extensions \
39-
ros-${ROS_DISTRO}-ament-cmake \
40-
ros-${ROS_DISTRO}-ament-cmake-pytest \
24+
libx11-6 \
25+
libxext6 \
26+
libxrender1 \
27+
libxrandr2 \
28+
libxinerama1 \
29+
libxcursor1 \
30+
libxfixes3 \
31+
libxi6 \
32+
libgl1 \
33+
libgl1-mesa-dri \
34+
libglx-mesa0 \
35+
libegl1 \
36+
libglib2.0-0 \
37+
libfontconfig1 \
38+
libfreetype6 \
39+
libdbus-1-3 \
40+
mesa-utils \
41+
x11-apps \
4142
&& rm -rf /var/lib/apt/lists/*
4243

43-
# create ubuntu user (only needed for Ubuntu 22.04 as it doesn't exist in base image)
44-
# Note: Ubuntu 24.04 base images already include the ubuntu user with uid=1000, gid=1000
45-
RUN if [ "$UBUNTU_VERSION" = "22.04" ]; then \
46-
groupadd --gid 1000 ubuntu \
47-
&& useradd --uid 1000 --gid 1000 -m ubuntu; \
48-
fi
49-
5044
# non-root user installation stuff
5145
USER ubuntu
5246
WORKDIR /home/ubuntu
@@ -56,106 +50,17 @@ COPY --chown=ubuntu:ubuntu . ./roboreg
5650
ENV PIP_NO_CACHE_DIR=1
5751
SHELL ["/bin/bash", "-c"]
5852

59-
# clone the LBR-Stack and xarm source code for robot description only
60-
RUN mkdir -p roboreg-deployment/src \
61-
&& git clone \
62-
--depth 1 \
63-
-b $ROS_DISTRO \
64-
https://github.com/lbr-stack/lbr_fri_ros2_stack.git roboreg-deployment/src/lbr_fri_ros2_stack \
65-
&& git clone \
66-
--depth 1 \
67-
-b $ROS_DISTRO \
68-
--recursive \
69-
--shallow-submodules \
70-
https://github.com/xArm-Developer/xarm_ros2.git roboreg-deployment/src/xarm_ros2
53+
# extend PATH (for CLI)
54+
ENV PATH="$PATH:/home/ubuntu/.local/bin"
7155

72-
# create a virtual environment and install roboreg
73-
RUN cd roboreg-deployment \
74-
&& python3 -m venv roboreg-venv \
75-
&& touch roboreg-venv/COLCON_IGNORE \
76-
&& cd .. \
77-
&& source roboreg-deployment/roboreg-venv/bin/activate \
78-
&& pip3 install roboreg/ \
56+
# install roboreg
57+
RUN pip install --upgrade pip setuptools wheel \
58+
&& pip install roboreg/ --no-build-isolation \
7959
&& rm -rf /home/ubuntu/.cache/pip
8060

81-
# install robot description files
82-
RUN cd roboreg-deployment \
83-
&& source /opt/ros/${ROS_DISTRO}/setup.bash \
84-
&& colcon build \
85-
--cmake-args -DBUILD_TESTING=0 \
86-
--packages-select \
87-
xarm_description \
88-
lbr_description \
89-
&& rm -rf \
90-
roboreg-deployment/build \
91-
roboreg-deployment/log \
92-
roboreg-deployment/src \
93-
/home/ubuntu/.cache \
94-
/tmp/*
95-
96-
FROM nvidia/cuda:${CUDA_VERSION}-base-ubuntu${UBUNTU_VERSION} AS runtime
97-
98-
# Re-declare ARGs after FROM to make them available in this stage
99-
ARG CUDA_VERSION
100-
ARG UBUNTU_VERSION
101-
ARG ROS_DISTRO
102-
103-
# setup
104-
ENV DEBIAN_FRONTEND=noninteractive
105-
ENV ROS_DISTRO=${ROS_DISTRO}
106-
# create ubuntu user and add to sudoers (only needed for Ubuntu 22.04 as it doesn't exist in base image)
107-
# Note: Ubuntu 24.04 CUDA base images already include the ubuntu user with uid=1000, gid=1000
108-
RUN if [ "$UBUNTU_VERSION" = "22.04" ]; then \
109-
groupadd --gid 1000 ubuntu \
110-
&& useradd --uid 1000 --gid 1000 -m ubuntu; \
111-
fi \
112-
# add ubuntu to sudoers: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
113-
&& apt-get update \
114-
&& apt-get install -y sudo \
115-
&& echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
116-
&& chmod 0440 /etc/sudoers.d/ubuntu \
117-
&& rm -rf /var/lib/apt/lists/*
118-
119-
# install runtime dependencies
120-
RUN apt-get update \
121-
# add ROS 2 sources, see e.g. https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
122-
&& apt-get install -y \
123-
software-properties-common \
124-
&& add-apt-repository universe \
125-
&& apt-get update \
126-
&& apt-get install -y \
127-
curl \
128-
&& curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
129-
&& 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 \
130-
&& apt-get update \
131-
# install minimal runtime utilities
132-
&& apt-get install -y \
133-
python3 \
134-
ros-${ROS_DISTRO}-ament-index-python \
135-
ros-${ROS_DISTRO}-xacro \
136-
libgl1 \
137-
libxrender1 \
138-
# python3-setuptools only needed for Ubuntu 22.04
139-
&& if [ "$UBUNTU_VERSION" = "22.04" ]; then \
140-
apt-get install -y python3-setuptools; \
141-
fi \
142-
&& rm -rf /var/lib/apt/lists/*
143-
144-
# copy roboreg-deployment from builder stage
145-
COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg-deployment/roboreg-venv /home/ubuntu/roboreg-deployment/roboreg-venv
146-
COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg-deployment/install /home/ubuntu/roboreg-deployment/install
147-
COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg/test/assets /home/ubuntu/sample-data
148-
149-
# non-root user
150-
USER ubuntu
151-
WORKDIR /home/ubuntu
152-
153-
# source ROS 2 workspace
154-
RUN echo "source /home/ubuntu/roboreg-deployment/install/setup.bash" >> .bashrc
155-
RUN echo "source /home/ubuntu/roboreg-deployment/roboreg-venv/bin/activate" >> .bashrc
156-
157-
# extend PATH (for CLI)
158-
ENV PATH="$PATH:/home/ubuntu/roboreg-deployment/roboreg-venv/bin"
61+
# copy sample data
62+
RUN mkdir sample-data \
63+
&& cp -r roboreg/test/assets/* sample-data/
15964

16065
# run inside the roboreg folder (where data is located)
16166
CMD ["/bin/bash"]

.github/workflows/docker.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
- ubuntu_version: "22.04"
16-
cuda_version: "12.4.1"
17-
ros_distro: "humble"
18-
- ubuntu_version: "24.04"
19-
cuda_version: "13.1.0"
20-
ros_distro: "jazzy"
15+
- pytorch_version: "2.6.0"
16+
cuda_version: "12.4"
17+
- pytorch_version: "2.10.0"
18+
cuda_version: "13.1"
2119
steps:
20+
- name: Free disk space
21+
run: |
22+
sudo rm -rf /usr/share/dotnet
23+
sudo rm -rf /opt/ghc
24+
sudo rm -rf /usr/local/lib/android
25+
sudo rm -rf /usr/local/.ghcup
26+
df -h
27+
2228
- name: Login to GitHub Container Registry
2329
uses: docker/login-action@v3
2430
with:
@@ -38,10 +44,9 @@ jobs:
3844
platforms: linux/amd64
3945
file: .docker/Dockerfile
4046
build-args: |
41-
UBUNTU_VERSION=${{ matrix.ubuntu_version }}
47+
PYTORCH_VERSION=${{ matrix.pytorch_version }}
4248
CUDA_VERSION=${{ matrix.cuda_version }}
43-
ROS_DISTRO=${{ matrix.ros_distro }}
4449
push: ${{ github.ref == 'refs/heads/main' }}
4550
tags: |
46-
roboreg:${{ matrix.ubuntu_version }}
47-
ghcr.io/lbr-stack/roboreg:${{ matrix.ubuntu_version }}
51+
roboreg:cuda-${{ matrix.cuda_version }}
52+
ghcr.io/lbr-stack/roboreg:cuda-${{ matrix.cuda_version }}

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,19 @@ Next:
9494
docker build \
9595
-t roboreg:latest \
9696
-f .docker/Dockerfile \
97-
--build-arg UBUNTU_VERSION=24.04 \
98-
--build-arg CUDA_VERSION=13.1.0 \
99-
--build-arg ROS_DISTRO=jazzy \
97+
--build-arg PYTORCH_VERSION=2.10.0 \
98+
--build-arg CUDA_VERSION=13.0 \
10099
.
101100
```
102101

103-
For Ubuntu 22.04 with ROS 2 Humble and CUDA 12.4.1, use:
102+
For CUDA 12.4, use:
104103

105104
```shell
106105
docker build \
107106
-t roboreg:latest \
108107
-f .docker/Dockerfile \
109-
--build-arg UBUNTU_VERSION=22.04 \
110-
--build-arg CUDA_VERSION=12.4.1 \
111-
--build-arg ROS_DISTRO=humble \
108+
--build-arg PYTORCH_VERSION=2.6.0 \
109+
--build-arg CUDA_VERSION=12.4 \
112110
.
113111
```
114112

0 commit comments

Comments
 (0)