Dockerfile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # Copyright (c) Contributors to the Open 3D Engine Project.
  2. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #
  6. ARG ROS_VERSION=humble
  7. ARG UBUNTU_VERSION=jammy
  8. FROM ros:${ROS_VERSION}-ros-base-${UBUNTU_VERSION}
  9. ENV WORKSPACE=/data/workspace
  10. WORKDIR $WORKSPACE
  11. # O3DE Variables
  12. ARG O3DE_REPO=https://github.com/o3de/o3de.git
  13. ARG O3DE_BRANCH=main
  14. ARG O3DE_COMMIT=2310.1
  15. ENV O3DE_ROOT=$WORKSPACE/o3de
  16. # O3DE Extras Variables
  17. ARG O3DE_EXTRAS_REPO=https://github.com/o3de/o3de-extras.git
  18. ARG O3DE_EXTRAS_BRANCH=main
  19. ARG O3DE_EXTRAS_COMMIT=2310.1
  20. ENV O3DE_EXTRAS_ROOT=$WORKSPACE/o3de-extras
  21. # ROSConDemo Variables
  22. ARG ROSCON_DEMO_REPO=https://github.com/o3de/ROSConDemo.git
  23. ARG ROSCON_DEMO_BRANCH=main
  24. ARG ROSCON_DEMO_COMMIT=HEAD
  25. ENV ROSCON_DEMO_ROOT=$WORKSPACE/ROSConDemo
  26. ENV ROSCON_DEMO_PROJECT=$ROSCON_DEMO_ROOT/Project
  27. ENV ROSCON_DEMO_NAV_ROOT=$ROSCON_DEMO_ROOT/kraken_nav
  28. # Copy the release-patch in case its needed
  29. COPY o3de_2.1.0.patch $WORKSPACE/
  30. ENV LANG=en_US.UTF-8
  31. # Setup time zone and locale data (necessary for SSL and HTTPS packages)
  32. RUN apt-get update \
  33. && DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata locales keyboard-configuration curl \
  34. && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
  35. && dpkg-reconfigure --frontend=noninteractive locales \
  36. && update-locale LANG=en_US.UTF-8 \
  37. && sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list' \
  38. && curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - \
  39. && rm -rf /var/lib/apt/lists/*
  40. # Install the required ubuntu packages
  41. RUN apt-get update \
  42. && apt-get install -y \
  43. binutils \
  44. clang \
  45. cmake \
  46. git \
  47. git-lfs \
  48. libglu1-mesa-dev \
  49. libxcb-xinerama0 \
  50. libfontconfig1-dev \
  51. libnvidia-gl-470 \
  52. libxcb-xkb-dev \
  53. libxkbcommon-x11-dev \
  54. libxkbcommon-dev \
  55. libxcb-xfixes0-dev \
  56. libxcb-xinput-dev \
  57. libxcb-xinput0 \
  58. libpcre2-16-0 \
  59. ninja-build \
  60. python3-pip \
  61. software-properties-common \
  62. ros-${ROS_DISTRO}-ackermann-msgs \
  63. ros-${ROS_DISTRO}-control-toolbox \
  64. ros-${ROS_DISTRO}-gazebo-msgs \
  65. ros-${ROS_DISTRO}-joy \
  66. ros-${ROS_DISTRO}-navigation2 \
  67. ros-${ROS_DISTRO}-rviz2 \
  68. ros-${ROS_DISTRO}-tf2-ros \
  69. ros-${ROS_DISTRO}-urdfdom \
  70. ros-${ROS_DISTRO}-vision-msgs \
  71. ros-${ROS_DISTRO}-cyclonedds \
  72. ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
  73. ros-${ROS_DISTRO}-slam-toolbox \
  74. ros-${ROS_DISTRO}-nav2-bringup \
  75. ros-${ROS_DISTRO}-pointcloud-to-laserscan \
  76. ros-${ROS_DISTRO}-teleop-twist-keyboard \
  77. ros-${ROS_DISTRO}-topic-tools \
  78. python3-colcon-common-extensions \
  79. && rm -rf /var/lib/apt/lists/* \
  80. && pip install python-statemachine
  81. ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
  82. # Clone, register, and build the projects
  83. RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
  84. \
  85. # Clone o3de \
  86. \
  87. && git clone --single-branch -b $O3DE_BRANCH $O3DE_REPO $O3DE_ROOT \
  88. && git -C $O3DE_ROOT lfs install \
  89. && git -C $O3DE_ROOT lfs pull \
  90. && git -C $O3DE_ROOT reset --hard $O3DE_COMMIT \
  91. \
  92. ############################################################### \
  93. # Apply a patch to fix a release compile issue if needed \
  94. ############################################################### \
  95. && if [ "$(md5sum $O3DE_ROOT/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp | awk '{print $1}')" = "07389c00378a13f31f1d6faf097a026b" ];then git -C $O3DE_ROOT apply $WORKSPACE/o3de_2.1.0.patch; fi \
  96. \
  97. ############################################################### \
  98. # Clone o3de-extras \
  99. ############################################################### \
  100. && git clone --single-branch -b $O3DE_EXTRAS_BRANCH $O3DE_EXTRAS_REPO $O3DE_EXTRAS_ROOT \
  101. && git -C $O3DE_EXTRAS_ROOT lfs install \
  102. && git -C $O3DE_EXTRAS_ROOT lfs pull \
  103. && git -C $O3DE_EXTRAS_ROOT reset --hard $O3DE_EXTRAS_COMMIT \
  104. \
  105. ############################################################### \
  106. # Clone the ROSConDemo \
  107. ############################################################### \
  108. && git clone --single-branch -b $ROSCON_DEMO_BRANCH $ROSCON_DEMO_REPO $ROSCON_DEMO_ROOT \
  109. && git -C $ROSCON_DEMO_ROOT lfs install \
  110. && git -C $ROSCON_DEMO_ROOT lfs pull \
  111. && git -C $ROSCON_DEMO_ROOT reset --hard $ROSCON_DEMO_COMMIT \
  112. \
  113. ############################################################### \
  114. # Get the O3DE python and register the gem paths and projects \
  115. ############################################################### \
  116. && $O3DE_ROOT/python/get_python.sh \
  117. && $O3DE_ROOT/scripts/o3de.sh register -ep $O3DE_ROOT \
  118. && $O3DE_ROOT/scripts/o3de.sh register -gp $O3DE_EXTRAS_ROOT/Gems/ROS2 \
  119. && $O3DE_ROOT/scripts/o3de.sh register -pp $ROSCON_DEMO_PROJECT \
  120. \
  121. ############################################################### \
  122. # Build the Editor, Tools, and clients
  123. ############################################################### \
  124. && cmake -B $ROSCON_DEMO_PROJECT/build/linux -G "Ninja Multi-Config" \
  125. -S $ROSCON_DEMO_PROJECT \
  126. -DLY_DISABLE_TEST_MODULES=ON \
  127. -DLY_STRIP_DEBUG_SYMBOLS=ON \
  128. -DAZ_USE_PHYSX5=ON \
  129. && cmake --build $ROSCON_DEMO_PROJECT/build/linux --config profile \
  130. --target ROSConDemo.GameLauncher Editor ROSConDemo.Assets \
  131. \
  132. ############################################################### \
  133. # Remove build artifacts
  134. ############################################################### \
  135. && rm -rf ~/.o3de/3rdParty/ \
  136. && rm -rf $O3DE_ROOT/.git \
  137. && rm -rf $O3DE_ROOT/AutomatedTesting \
  138. && rm -rf $O3DE_ROOT/python/downloaded_packages \
  139. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/Azcg/ \
  140. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/CMake \
  141. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/CMakeFiles/ \
  142. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/External/ \
  143. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/Testing/ \
  144. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/_deps/ \
  145. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/cmake \
  146. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/lib/ \
  147. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/o3de/ \
  148. && rm -rf $ROSCON_DEMO_PROJECT/build/linux/packages/
  149. # Build the navigation stack
  150. RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
  151. && cd $ROSCON_DEMO_NAV_ROOT \
  152. && colcon build --symlink-install
  153. # Add the appropriate ros2 environment setup script to the system startup
  154. RUN echo "[Unit]" > /etc/systemd/system/setup_ros.service \
  155. && echo "After=network.target" >> /etc/systemd/system/setup_ros.service \
  156. && echo "" >> /etc/systemd/system/setup_ros.service \
  157. && echo "[Service]" >> /etc/systemd/system/setup_ros.service \
  158. && if [ "${ROS_DISTRO}" = "iron" ]; then \
  159. echo "ExecStart=/opt/ros/iron/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  160. elif [ "${ROS_DISTRO}" = "humble" ]; then \
  161. echo "ExecStart=/opt/ros/humble/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  162. elif [ "${ROS_DISTRO}" = "galactic" ]; then \
  163. echo "ExecStart=/opt/ros/galactic/setup.bash" >> /etc/systemd/system/setup_ros.service; \
  164. fi \
  165. && echo "" >> /etc/systemd/system/setup_ros.service \
  166. && echo "[Install]" >> /etc/systemd/system/setup_ros.service \
  167. && echo "WantedBy=default.target" >> /etc/systemd/system/setup_ros.service \
  168. && echo "" >> /etc/systemd/system/setup_ros.service
  169. ENV NVIDIA_VISIBLE_DEVICES all
  170. ENV NVIDIA_DRIVER_CAPABILITIES all