|
| 1 | +# Copyright 2024 Open Source Robotics Foundation, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# A Docker configuration script to build the Space ROS image. |
| 16 | +# |
| 17 | +# The script provides the following build arguments: |
| 18 | +# |
| 19 | +# VCS_REF - The git revision of the Space ROS source code (no default value). |
| 20 | +# VERSION - The version of Space ROS (default: "preview") |
| 21 | + |
| 22 | +FROM osrf/space-ros:latest |
| 23 | + |
| 24 | +# Define arguments used in the metadata definition |
| 25 | +ARG VCS_REF |
| 26 | +ARG VERSION="preview" |
| 27 | + |
| 28 | +# Specify the docker image metadata |
| 29 | +LABEL org.label-schema.schema-version="1.0" |
| 30 | +LABEL org.label-schema.name="Real World Extraterrestrial Simulations" |
| 31 | +LABEL org.label-schema.description="Realistic Extraterrestrial Simulations demos using custom GZ plugins & data from NASA PDS" |
| 32 | +LABEL org.label-schema.vendor="Open Robotics" |
| 33 | +LABEL org.label-schema.version=${VERSION} |
| 34 | +LABEL org.label-schema.url="https://github.com/space-ros" |
| 35 | +LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker" |
| 36 | +LABEL org.label-schema.vcs-ref=${VCS_REF} |
| 37 | + |
| 38 | +# Define a few key variables |
| 39 | +ENV DEMO_DIR=${HOME_DIR}/demos_ws |
| 40 | +ENV GZ_VERSION=harmonic |
| 41 | + |
| 42 | +# Disable prompting during package installation |
| 43 | +ARG DEBIAN_FRONTEND=noninteractive |
| 44 | + |
| 45 | +# Clone all space-ros sources |
| 46 | +RUN mkdir ${SPACEROS_DIR}/src \ |
| 47 | + && vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos |
| 48 | + |
| 49 | +# Make sure the latest versions of packages are installed |
| 50 | +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that |
| 51 | +# the cache won't make it into the built image but will be maintained between steps. |
| 52 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 53 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 54 | + sudo apt-get update |
| 55 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 56 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 57 | + sudo apt-get dist-upgrade -y |
| 58 | +RUN rosdep update |
| 59 | + |
| 60 | +# Get rosinstall_generator |
| 61 | +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that |
| 62 | +# the cache won't make it into the built image but will be maintained between steps. |
| 63 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 64 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 65 | + sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator |
| 66 | + |
| 67 | +RUN mkdir -p ${DEMO_DIR}/src |
| 68 | +WORKDIR ${DEMO_DIR} |
| 69 | + |
| 70 | +# Install libmongoc for development |
| 71 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 72 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 73 | + sudo apt-get install libmongoc-dev -y |
| 74 | + |
| 75 | +# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/ |
| 76 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 77 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 78 | + sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y |
| 79 | +RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz |
| 80 | +RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz |
| 81 | +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 |
| 82 | + |
| 83 | +# Add osrf packages repository and manually install gz sim harmonic dependecies as they haven't been added to the rosdep index as of yet |
| 84 | +RUN sudo curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg |
| 85 | +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null |
| 86 | +RUN sudo apt-get update && sudo apt-get install -y libgz-math7-dev libgz-transport13-dev libgz-sim8-dev libgz-msgs10-dev libgz-plugin2-dev |
| 87 | + |
| 88 | +# Get the source for the dependencies |
| 89 | +COPY --chown=${USERNAME}:${USERNAME} dependencies_source_pkgs.repos /tmp/ |
| 90 | +RUN vcs import src < /tmp/dependencies_source_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' |
| 91 | + |
| 92 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 93 | +--mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 94 | +sudo apt-get update -y \ |
| 95 | +&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ |
| 96 | +&& rosdep install --from-paths ${SPACEROS_DIR}/src src --ignore-src -r -y --rosdistro ${ROSDISTRO} --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py" |
| 97 | + |
| 98 | +# Build the demo |
| 99 | +RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ |
| 100 | + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release' |
| 101 | + |
| 102 | +# Add the user to the render group so that the user can access /dev/dri/renderD128 |
| 103 | +RUN sudo usermod -aG render $USERNAME |
| 104 | + |
| 105 | +# Setup the entrypoint |
| 106 | +COPY ./entrypoint.sh / |
| 107 | +ENTRYPOINT ["/entrypoint.sh"] |
| 108 | +CMD ["bash"] |
0 commit comments