Skip to content

Commit

Permalink
Optimized dockerfile (#54)
Browse files Browse the repository at this point in the history
* Optimized dockerfile

- Made build time quicker
- Switch to rolling
- Used drake-noble-1.30.0

* pre-commit fix

* Updated readme ( see #54 (comment) )

* Deleted drake deb after installing and fixed typo in dockerfile

* Added Drake version as an argument and fixed some overlooked stuffs

* Give docker arguments through docker compose yaml

---------

Co-authored-by: DarkusAlphaHydranoid <[email protected]>
  • Loading branch information
CihatAltiparmak and DarkusAlphaHydranoid authored Oct 14, 2024
1 parent fec4b0a commit df7d3b4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 64 deletions.
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 [email protected]"
ARG ROS_DISTRO=rolling
ARG RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ARG DRAKE_VERSION=1.30.0-1

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 [email protected]"

# 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:
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
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ services:
build:
context: .
dockerfile: .docker/Dockerfile
args:
- ROS_DISTRO=rolling
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
- DRAKE_VERSION=1.30.0-1
environment:
- DISPLAY=${DISPLAY}
- QT_X11_NO_MITSHM=1
Expand Down

0 comments on commit df7d3b4

Please sign in to comment.