Skip to content

Commit

Permalink
update dockerfile space-ros#36
Browse files Browse the repository at this point in the history
Signed-off-by: stevedan <stevedan.o.omodolor@gmail.com>
  • Loading branch information
stevedanomodolor authored and mkhansenbot committed Sep 9, 2024
1 parent 5c56110 commit 201d2a6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 32 deletions.
68 changes: 36 additions & 32 deletions lunar_pole_exploration_rover/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2021 Open Source Robotics Foundation, Inc.
# Copyright 2024 Stevedan Ogochukwu Omodolor Omodolor
# Copyright 2024 Robin Baran
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# A Docker configuration script to build the Space ROS image.
# A Docker configuration script to build the MoveIt2/Space ROS image.
#
# The script provides the following build arguments:
#
Expand All @@ -27,36 +28,30 @@ ARG VERSION="preview"

# Specify the docker image metadata
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="Lunar Pole Exploration Rover"
LABEL org.label-schema.description="Lunar Pole Exploration Rover entry for the NASA Space ROS Sim Summer Sprint Challenge"
LABEL org.label-schema.name="MoveIt2"
LABEL org.label-schema.description="Preview version of the MoveIt2/Space ROS platform"
LABEL org.label-schema.vendor="Open Robotics"
LABEL org.label-schema.version=${VERSION}
LABEL org.label-schema.url="https://github.com/space-ros"
LABEL org.label-schema.vcs-url="https://github.com/space-ros/demos"
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker-images"
LABEL org.label-schema.vcs-ref=${VCS_REF}

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive

# Define a few key variables
ENV DEMO_DIR=${HOME_DIR}/demos_ws
ENV IGNITION_VERSION=fortress
ENV GZ_VERSION=fortress

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive


# Get rosinstall_generator
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
# the cache won't make it into the built image but will be maintained between steps.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator
# Clone all space-ros sources
RUN mkdir ${SPACEROS_DIR}/src \
&& vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos

# Disable prompting during package installation
ARG DEBIAN_FRONTEND=noninteractive
# Define key locations
RUN mkdir -p ${DEMO_DIR}/src
WORKDIR ${DEMO_DIR}

# # Clone all space-ros sources
# RUN mkdir ${SPACEROS_DIR}/src \
# && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos

# Make sure the latest versions of packages are installed
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
Expand Down Expand Up @@ -102,13 +97,6 @@ RUN python3 -m pip install -U \
pytest-rerunfailures \
pytest

RUN mkdir -p ${DEMO_DIR}/src
WORKDIR ${DEMO_DIR}

# Update the ownership of the source files (had to use sudo above to work around
# a possible inherited 'insteadof' from the host that forces use of ssh
RUN sudo chown -R ${USERNAME}:${USERNAME} ${DEMO_DIR}

# Get rosinstall_generator
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Expand All @@ -119,6 +107,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get install libmongoc-dev -y


# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Expand All @@ -127,9 +116,23 @@ RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mo
RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz
RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install



# Generate repos file for dependencies, excluding packages from Space ROS core.
COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/
COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/
RUN rosinstall_generator \
--rosdistro ${ROSDISTRO} \
--deps \
--exclude-path ${SPACEROS_DIR}/src \
--exclude $(cat /tmp/excluded-pkgs.txt) -- \
-- $(cat /tmp/demo-pkgs.txt) \
> /tmp/demo_generated_pkgs.repos

RUN vcs import src < /tmp/demo_generated_pkgs.repos

# Get the source for the dependencies
# RUN vcs import src < /tmp/demo_generated_pkgs.repos
COPY --chown=${USERNAME}:${USERNAME} ./demo_manual_pkgs.repos /tmp/
COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/
RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"'

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
Expand All @@ -138,9 +141,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \
&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO}

# Build the demo
# build demo
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release'
&& colcon build --executo sequential --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-'


# Add the user to the render group so that the user can access /dev/dri/renderD128
RUN sudo usermod -aG render $USERNAME
Expand All @@ -159,4 +163,4 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
# Setup the entrypoint
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
CMD ["bash"]
9 changes: 9 additions & 0 deletions lunar_pole_exploration_rover/docker/demo-pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
angles
backward_ros
control_msgs
rviz2
ros2_control
warehouse_ros
xacro
yaml_cpp_vendor
python_qt_binding
10 changes: 10 additions & 0 deletions lunar_pole_exploration_rover/docker/excluded-pkgs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fastrtps
fastcdr
generate_parameter_library
rmw_fastrtps_cpp
rmw_fastrtps_dynamic_cpp
rmw_fastrtps_shared_cpp
rmw_connextdds
rosidl_typesupport_fastrtps_c
rosidl_typesupport_fastrtps_cpp
fastrtps_cmake_module

0 comments on commit 201d2a6

Please sign in to comment.