Skip to content
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

Optimized dockerfile #54

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 36 additions & 60 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,71 +1,47 @@
FROM robotlocomotion/drake:1.29.0
LABEL maintainer="Aditya Kamireddypalli kamireddypalliaditya@gmail.com"
ARG ROS_DISTRO=rolling
ARG RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ARG DRAKE_VERSION=1.30.0-1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these are default values, maybe give it through docker compose?

Copy link
Member Author

@CihatAltiparmak CihatAltiparmak Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall done it with a couple of details: I couldn't build docker image without setting default argument inside dockerfile. So i just have updated docker-compose yaml instead of changing dockerfile as well. Now we can change args through compose file.

ENV ROS_DISTRO=humble
ENV WORKSPACE=/root/workspace/
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV DEBIAN_FRONTEND=noninteractive
FROM moveit/moveit2:${ROS_DISTRO}-source
LABEL maintainer="Aditya Kamireddypalli kamireddypalliaditya@gmail.com"

# ROS installation
RUN apt update && \
apt install locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8
ARG ROS_DISTRO
ARG RMW_IMPLEMENTATION
ARG DRAKE_VERSION

RUN apt install -y software-properties-common && \
add-apt-repository universe
ENV DEBIAN_FRONTEND=noninteractive
ENV WORKSPACE=${ROS_UNDERLAY}/..

COPY . ${WORKSPACE}/src/moveit_drake

RUN apt-get update && \
apt-get install --no-install-recommends \
ca-certificates \
gnupg \
lsb-release \
wget -y && \
wget -qO- https://drake-apt.csail.mit.edu/drake.asc | gpg --dearmor - \
| sudo tee /etc/apt/trusted.gpg.d/drake.gpg >/dev/null && \
echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/$(lsb_release -cs) $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/drake.list >/dev/null && \
apt-get update && \
apt-get install --no-install-recommends drake-dev=${DRAKE_VERSION} -y

RUN apt update && \
apt install -y curl git && \
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
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
cd ${WORKSPACE}/src && \
vcs import < moveit_drake/.docker/upstream.repos --recursive

RUN apt update && \
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
cd ${WORKSPACE} && \
rosdep update --rosdistro=$ROS_DISTRO && \
apt-get update && \
apt upgrade -y && \
apt install -y \
build-essential \
clang-format-14 \
clangd-12 \
cmake \
git-lfs \
python3-colcon-common-extensions \
python3-flake8 \
python3-rosdep \
python3-setuptools \
python3-vcstool \
ros-dev-tools \
ros-${ROS_DISTRO}-desktop \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
wget && \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-12 100

RUN pip3 install colcon-mixin pre-commit && \
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \
colcon mixin update default

RUN apt update && \
rosdep init && \
rosdep update

# Setup the workspace
WORKDIR ${WORKSPACE}
RUN mkdir -p src

# Install dependencies of this package
# NOTE: Copying only the necessary files to not bust cache as much.
COPY moveit_drake.repos ${WORKSPACE}/src/moveit_drake/
WORKDIR ${WORKSPACE}/src/
RUN vcs import < moveit_drake/moveit_drake.repos

WORKDIR ${WORKSPACE}
COPY package.xml ${WORKSPACE}/src/moveit_drake/
RUN apt update && \
. /opt/ros/${ROS_DISTRO}/setup.sh && \
rosdep install -r --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y && \
rm -rf src/moveit_drake
rosdep install --from-paths src --ignore-src -r -y && \
apt-get install ros-${ROS_DISTRO}-rmw-cyclonedds-cpp -y

RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
cd ${WORKSPACE} && \
. install/setup.sh && \
colcon build --mixin release --parallel-workers 1

# Set up the entrypoint
Expand Down
9 changes: 9 additions & 0 deletions .docker/upstream.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repositories:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is a moveit_drake.repos file at the top level. Can probably just keep one of these 2 files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually inspired from upstream.repos of moveit2_tutorials. While installing via docker, we don't need to clone repositories like moveit2 (they already installed in MoveIt's docker image) . In case of local installation, user need to clone additional repositories in addition of upstream.repos. Shortly, i have tried to support both local installation method and docker installation. But if you don't mind, we can only update main moveit_drake.repos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this seems to be the likely way to go forward. I am in favor of keeping both for now. This gives users the option of doing a single VCS import if working locally.

Could you add some instructions on README, under the local installation section to point users to this effect? May also be beneficial to specify that the build time is large in this case.

moveit_visual_tools:
type: git
url: https://github.com/moveit/moveit_visual_tools
version: ros2
rviz_visual_tools:
type: git
url: https://github.com/PickNikRobotics/rviz_visual_tools.git
version: ros2
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ rich specification of constraints and costs provided by `drake`.

### Steps
The following steps clone and build the base image that you will require to
test/build/run/develop with the repo (and will take some time, as it builds
moveit)
test/build/run/develop with the repo

git clone https://github.com/moveit/moveit_drake.git
cd moveit_drake
Expand Down Expand Up @@ -62,10 +61,11 @@ Download the MoveIt Tutorials source code:
vcs import < moveit_drake/moveit_drake.repos
rosdep install -r --from-paths . --ignore-src --rosdistro ${ROS_DISTRO} -y

Configure and build the workspace:
Configure and build the workspace (this will take some time, as it builds
moveit):

cd ${WORKSPACE}
colcon build --event-handlers desktop_notification- status- --cmake-args -DCMAKE_BUILD_TYPE=Release
colcon build --event-handlers desktop_notification- status- --cmake-args -DCMAKE_BUILD_TYPE=Release --parallel-workers 1

### Run the demo

Expand Down
Loading