-
Notifications
You must be signed in to change notification settings - Fork 2
remove ROS from Docker #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,161 +1,73 @@ | ||
| # Build arguments for version configuration | ||
| ARG UBUNTU_VERSION=24.04 | ||
| ARG CUDA_VERSION=13.1.0 | ||
| ARG ROS_DISTRO=jazzy | ||
| ARG PYTORCH_VERSION=2.6.0 | ||
| ARG CUDA_VERSION=12.4 | ||
|
|
||
| FROM ubuntu:${UBUNTU_VERSION} AS builder | ||
|
|
||
| # Re-declare ARG after FROM to make it available in this stage | ||
| ARG ROS_DISTRO | ||
| ARG UBUNTU_VERSION | ||
| FROM pytorch/pytorch:${PYTORCH_VERSION}-cuda${CUDA_VERSION}-cudnn9-runtime | ||
|
|
||
| # setup | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV ROS_DISTRO=${ROS_DISTRO} | ||
|
|
||
| # install build dependencies | ||
| RUN apt-get update \ | ||
| # add ROS 2 sources, see e.g. https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html | ||
| && apt-get install -y \ | ||
| software-properties-common \ | ||
| && add-apt-repository universe \ | ||
| && apt-get update \ | ||
| && apt-get install -y \ | ||
| curl \ | ||
| && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \ | ||
| && 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 \ | ||
| && apt-get update \ | ||
| # install build tools (unavailable in base image and only required for builder stage) | ||
| && apt-get install -y \ | ||
| git \ | ||
| cmake \ | ||
| python3 \ | ||
| python3-venv \ | ||
| python3-pip \ | ||
| # install minimal ROS 2 build utilities | ||
| # remove ament_cmake_pytest on https://github.com/lbr-stack/lbr_fri_ros2_stack/issues/372 | ||
| && apt-get install -y \ | ||
| python3-colcon-common-extensions \ | ||
| ros-${ROS_DISTRO}-ament-cmake \ | ||
| ros-${ROS_DISTRO}-ament-cmake-pytest \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # create ubuntu user (only needed for Ubuntu 22.04 as it doesn't exist in base image) | ||
| # Note: Ubuntu 24.04 base images already include the ubuntu user with uid=1000, gid=1000 | ||
| RUN if [ "$UBUNTU_VERSION" = "22.04" ]; then \ | ||
| groupadd --gid 1000 ubuntu \ | ||
| && useradd --uid 1000 --gid 1000 -m ubuntu; \ | ||
| fi | ||
|
|
||
| # non-root user installation stuff | ||
| USER ubuntu | ||
| WORKDIR /home/ubuntu | ||
|
|
||
| # setup | ||
| COPY --chown=ubuntu:ubuntu . ./roboreg | ||
| ENV PIP_NO_CACHE_DIR=1 | ||
| SHELL ["/bin/bash", "-c"] | ||
|
|
||
| # clone the LBR-Stack and xarm source code for robot description only | ||
| RUN mkdir -p roboreg-deployment/src \ | ||
| && git clone \ | ||
| --depth 1 \ | ||
| -b $ROS_DISTRO \ | ||
| https://github.com/lbr-stack/lbr_fri_ros2_stack.git roboreg-deployment/src/lbr_fri_ros2_stack \ | ||
| && git clone \ | ||
| --depth 1 \ | ||
| -b $ROS_DISTRO \ | ||
| --recursive \ | ||
| --shallow-submodules \ | ||
| https://github.com/xArm-Developer/xarm_ros2.git roboreg-deployment/src/xarm_ros2 | ||
|
|
||
| # create a virtual environment and install roboreg | ||
| RUN cd roboreg-deployment \ | ||
| && python3 -m venv roboreg-venv \ | ||
| && touch roboreg-venv/COLCON_IGNORE \ | ||
| && cd .. \ | ||
| && source roboreg-deployment/roboreg-venv/bin/activate \ | ||
| && pip3 install roboreg/ \ | ||
| && rm -rf /home/ubuntu/.cache/pip | ||
|
|
||
| # install robot description files | ||
| RUN cd roboreg-deployment \ | ||
| && source /opt/ros/${ROS_DISTRO}/setup.bash \ | ||
| && colcon build \ | ||
| --cmake-args -DBUILD_TESTING=0 \ | ||
| --packages-select \ | ||
| xarm_description \ | ||
| lbr_description \ | ||
| && rm -rf \ | ||
| roboreg-deployment/build \ | ||
| roboreg-deployment/log \ | ||
| roboreg-deployment/src \ | ||
| /home/ubuntu/.cache \ | ||
| /tmp/* | ||
|
|
||
| FROM nvidia/cuda:${CUDA_VERSION}-base-ubuntu${UBUNTU_VERSION} AS runtime | ||
|
|
||
| # Re-declare ARGs after FROM to make them available in this stage | ||
| ARG CUDA_VERSION | ||
| ARG UBUNTU_VERSION | ||
| ARG ROS_DISTRO | ||
|
|
||
| # setup | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV ROS_DISTRO=${ROS_DISTRO} | ||
| # create ubuntu user and add to sudoers (only needed for Ubuntu 22.04 as it doesn't exist in base image) | ||
| # Note: Ubuntu 24.04 CUDA base images already include the ubuntu user with uid=1000, gid=1000 | ||
| RUN if [ "$UBUNTU_VERSION" = "22.04" ]; then \ | ||
| groupadd --gid 1000 ubuntu \ | ||
| && useradd --uid 1000 --gid 1000 -m ubuntu; \ | ||
| fi \ | ||
| # create ubuntu user only if it doesn't exist yet | ||
| RUN getent group ubuntu || groupadd --gid 1000 ubuntu \ | ||
| && id -u ubuntu >/dev/null 2>&1 || useradd --uid 1000 --gid 1000 -m ubuntu \ | ||
| # add ubuntu to sudoers: https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user | ||
| && apt-get update \ | ||
| && apt-get install -y sudo \ | ||
| && echo ubuntu ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/ubuntu \ | ||
| && chmod 0440 /etc/sudoers.d/ubuntu \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # install runtime dependencies | ||
| # install dependencies (most for displaying, can be removed if not needed) | ||
| RUN apt-get update \ | ||
| # add ROS 2 sources, see e.g. https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html | ||
| && apt-get install -y \ | ||
| software-properties-common \ | ||
| && add-apt-repository universe \ | ||
| && apt-get update \ | ||
| && apt-get install -y \ | ||
| curl \ | ||
| && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \ | ||
| && 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 \ | ||
| && apt-get update \ | ||
| # install minimal runtime utilities | ||
| # install build tools (unavailable in base image and only required for builder stage) | ||
| && apt-get install -y \ | ||
| python3 \ | ||
| ros-${ROS_DISTRO}-ament-index-python \ | ||
| ros-${ROS_DISTRO}-xacro \ | ||
| libgl1 \ | ||
| libxrender1 \ | ||
| # python3-setuptools only needed for Ubuntu 22.04 | ||
| && if [ "$UBUNTU_VERSION" = "22.04" ]; then \ | ||
| apt-get install -y python3-setuptools; \ | ||
| fi \ | ||
| libx11-6 \ | ||
| libxext6 \ | ||
| libxrender1 \ | ||
| libxrandr2 \ | ||
| libxinerama1 \ | ||
| libxcursor1 \ | ||
| libxfixes3 \ | ||
| libxi6 \ | ||
| libgl1 \ | ||
| libgl1-mesa-dri \ | ||
| libglx-mesa0 \ | ||
| libegl1 \ | ||
| libglib2.0-0 \ | ||
| libfontconfig1 \ | ||
| libfreetype6 \ | ||
| libdbus-1-3 \ | ||
| mesa-utils \ | ||
| x11-apps \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # copy roboreg-deployment from builder stage | ||
| COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg-deployment/roboreg-venv /home/ubuntu/roboreg-deployment/roboreg-venv | ||
| COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg-deployment/install /home/ubuntu/roboreg-deployment/install | ||
| COPY --chown=ubuntu:ubuntu --from=builder /home/ubuntu/roboreg/test/assets /home/ubuntu/sample-data | ||
|
|
||
| # non-root user | ||
| # non-root user installation stuff | ||
| USER ubuntu | ||
| WORKDIR /home/ubuntu | ||
|
|
||
| # source ROS 2 workspace | ||
| RUN echo "source /home/ubuntu/roboreg-deployment/install/setup.bash" >> .bashrc | ||
| RUN echo "source /home/ubuntu/roboreg-deployment/roboreg-venv/bin/activate" >> .bashrc | ||
| # setup | ||
| COPY --chown=ubuntu:ubuntu . ./roboreg | ||
| ENV PIP_NO_CACHE_DIR=1 | ||
| SHELL ["/bin/bash", "-c"] | ||
|
|
||
| # extend PATH (for CLI) | ||
| ENV PATH="$PATH:/home/ubuntu/roboreg-deployment/roboreg-venv/bin" | ||
| ENV PATH="$PATH:/home/ubuntu/.local/bin" | ||
|
|
||
| # install roboreg (to use cached libraries, break system packages for Ubuntu 24.04) | ||
| RUN UBUNTU_VERSION=$(grep -oP '(?<=VERSION_ID=")[^"]+' /etc/os-release) && \ | ||
| echo "Detected Ubuntu $UBUNTU_VERSION" && \ | ||
| if [ "$UBUNTU_VERSION" = "24.04" ]; then \ | ||
| pip install --upgrade pip setuptools wheel --break-system-packages && \ | ||
| pip install roboreg/ --no-build-isolation --break-system-packages; \ | ||
| else \ | ||
| pip install --upgrade pip setuptools wheel && \ | ||
| pip install roboreg/ --no-build-isolation; \ | ||
| fi \ | ||
| && rm -rf /home/ubuntu/.cache/pip | ||
|
|
||
| # copy sample data | ||
| RUN mkdir sample-data \ | ||
| && cp -r roboreg/test/assets/* sample-data/ | ||
|
|
||
| # run inside the roboreg folder (where data is located) | ||
| CMD ["/bin/bash"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for future:
*-develimages support differentiable rendering, however, images are about 14.7GB in size