|
| 1 | +# Copyright 2024 Azmyin Md. Kamal |
| 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 o3de_curiosit_docker image that showcases Open 3D Engine |
| 16 | +# in simulating a Curiositry rover traversing through a test ground inspired by the NASA JPL Mars Yard |
| 17 | +# |
| 18 | +# The script provides the following build arguments: |
| 19 | +# |
| 20 | +# VCS_REF - The git revision of the Space ROS source code (no default value). |
| 21 | +# VERSION - The version of Space ROS (default: "preview") |
| 22 | + |
| 23 | +FROM openrobotics/moveit2:latest |
| 24 | + |
| 25 | +# Define arguments used in the metadata definition |
| 26 | +ARG VCS_REF |
| 27 | +ARG VERSION="preview" |
| 28 | + |
| 29 | +# Specify the docker image metadata |
| 30 | +LABEL org.label-schema.schema-version="1.0" |
| 31 | +LABEL org.label-schema.name="Curiosity Rover" |
| 32 | +LABEL org.label-schema.description="Curiosity rover demo on a new test enviornment on the Space ROS platform and Open 3D Engine" |
| 33 | +LABEL org.label-schema.vendor="Nasa Space ROS Sim Summer Spring Challenge 2024" |
| 34 | +LABEL org.label-schema.version=${VERSION} |
| 35 | +LABEL org.label-schema.url="https://github.com/space-ros" |
| 36 | +LABEL org.label-schema.vcs-url="https://github.com/Mechazo11/space-ros-docker" |
| 37 | +LABEL org.label-schema.vcs-ref=${VCS_REF} |
| 38 | + |
| 39 | +# Define a few key variables |
| 40 | +ENV DEMO_DIR=${HOME_DIR}/demos_ws |
| 41 | +ENV IGNITION_VERSION fortress |
| 42 | +ENV GZ_VERSION fortress |
| 43 | + |
| 44 | +# Disable prompting during package installation |
| 45 | +ARG DEBIAN_FRONTEND=noninteractive |
| 46 | + |
| 47 | +# Get rosinstall_generator |
| 48 | +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that |
| 49 | +# the cache won't make it into the built image but will be maintained between steps. |
| 50 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 51 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 52 | + sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator |
| 53 | + |
| 54 | +# TODO(anyone): remove demo-pkgs.txt, no packages left after exclusions |
| 55 | +# Generate repos file for demo dependencies, excluding packages from Space ROS core. |
| 56 | +# COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/ |
| 57 | +# COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/ |
| 58 | +# RUN rosinstall_generator \ |
| 59 | +# --rosdistro ${ROSDISTRO} \ |
| 60 | +# --deps \ |
| 61 | +# --exclude-path ${SPACEROS_DIR}/src \ |
| 62 | +# --exclude-path ${MOVEIT2_DIR}/src \ |
| 63 | +# --exclude $(cat /tmp/excluded-pkgs.txt) -- \ |
| 64 | +# -- $(cat /tmp/demo-pkgs.txt) \ |
| 65 | +# > /tmp/demo_generated_pkgs.repos |
| 66 | + |
| 67 | +RUN mkdir -p ${DEMO_DIR}/src |
| 68 | +WORKDIR ${DEMO_DIR} |
| 69 | + |
| 70 | + |
| 71 | +# Install libmongoc for development |
| 72 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 73 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 74 | + sudo apt-get install libmongoc-dev -y |
| 75 | + |
| 76 | +# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/ |
| 77 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 78 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 79 | + sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y |
| 80 | +RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz |
| 81 | +RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz |
| 82 | +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 |
| 83 | + |
| 84 | +# Get the source for the dependencies |
| 85 | +# RUN vcs import src < /tmp/demo_generated_pkgs.repos |
| 86 | +COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ |
| 87 | +RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' |
| 88 | + |
| 89 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 90 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 91 | + sudo apt-get update -y \ |
| 92 | +&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ |
| 93 | +&& /bin/bash -c 'source "${MOVEIT2_DIR}/install/setup.bash"' \ |
| 94 | +&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO} |
| 95 | + |
| 96 | +# Build the demo |
| 97 | +RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash && source ${MOVEIT2_DIR}/install/setup.bash \ |
| 98 | + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release' |
| 99 | + |
| 100 | +# Add the user to the render group so that the user can access /dev/dri/renderD128 |
| 101 | +RUN sudo usermod -aG render $USERNAME |
| 102 | + |
| 103 | +# Setup the entrypoint |
| 104 | +COPY ./entrypoint.sh / |
| 105 | +ENTRYPOINT ["/entrypoint.sh"] |
| 106 | +CMD ["bash"] |
0 commit comments