Skip to content

Commit 3cbffd0

Browse files
authored
Merge pull request #116 from lbr-stack/feature/roboreg-111/remove_ros
remove ROS from Docker
2 parents 87235ed + b7fe5e1 commit 3cbffd0

File tree

3 files changed

+68
-153
lines changed

3 files changed

+68
-153
lines changed

.docker/Dockerfile

Lines changed: 48 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,73 @@
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.6.0
3+
ARG CUDA_VERSION=12.4
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}
15-
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 \
27-
&& apt-get update \
28-
# install build tools (unavailable in base image and only required for builder stage)
29-
&& 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 \
41-
&& rm -rf /var/lib/apt/lists/*
42-
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
499

50-
# non-root user installation stuff
51-
USER ubuntu
52-
WORKDIR /home/ubuntu
53-
54-
# setup
55-
COPY --chown=ubuntu:ubuntu . ./roboreg
56-
ENV PIP_NO_CACHE_DIR=1
57-
SHELL ["/bin/bash", "-c"]
58-
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
71-
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/ \
79-
&& rm -rf /home/ubuntu/.cache/pip
80-
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 \
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 \
11213
# add ubuntu to sudoers: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user
11314
&& apt-get update \
11415
&& apt-get install -y sudo \
11516
&& echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \
11617
&& chmod 0440 /etc/sudoers.d/ubuntu \
11718
&& rm -rf /var/lib/apt/lists/*
11819

119-
# install runtime dependencies
20+
# install dependencies (most for displaying, can be removed if not needed)
12021
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
22+
# install build tools (unavailable in base image and only required for builder stage)
13223
&& 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 \
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 \
14242
&& rm -rf /var/lib/apt/lists/*
14343

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
44+
# non-root user installation stuff
15045
USER ubuntu
15146
WORKDIR /home/ubuntu
15247

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
48+
# setup
49+
COPY --chown=ubuntu:ubuntu . ./roboreg
50+
ENV PIP_NO_CACHE_DIR=1
51+
SHELL ["/bin/bash", "-c"]
15652

15753
# extend PATH (for CLI)
158-
ENV PATH="$PATH:/home/ubuntu/roboreg-deployment/roboreg-venv/bin"
54+
ENV PATH="$PATH:/home/ubuntu/.local/bin"
55+
56+
# install roboreg (to use cached libraries, break system packages for Ubuntu 24.04)
57+
RUN UBUNTU_VERSION=$(grep -oP '(?<=VERSION_ID=")[^"]+' /etc/os-release) && \
58+
echo "Detected Ubuntu $UBUNTU_VERSION" && \
59+
if [ "$UBUNTU_VERSION" = "24.04" ]; then \
60+
pip install --upgrade pip setuptools wheel --break-system-packages && \
61+
pip install roboreg/ --no-build-isolation --break-system-packages; \
62+
else \
63+
pip install --upgrade pip setuptools wheel && \
64+
pip install roboreg/ --no-build-isolation; \
65+
fi \
66+
&& rm -rf /home/ubuntu/.cache/pip
67+
68+
# copy sample data
69+
RUN mkdir sample-data \
70+
&& cp -r roboreg/test/assets/* sample-data/
15971

16072
# run inside the roboreg folder (where data is located)
16173
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.0"
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)