Dockerfile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. # Collect the arguments for the base ros image
  7. ARG ROS_VERSION=humble
  8. ARG UBUNTU_VERSION=jammy
  9. FROM ros:${ROS_VERSION}-ros-base-${UBUNTU_VERSION}
  10. ARG ROS_VERSION
  11. ARG UBUNTU_VERSION
  12. # Argument to determining the image type ('simulation' or 'navstack')
  13. ARG IMAGE_TYPE=simulation # Default to 'simulation'
  14. # Arguments for the source repos needed for the robot vacuum sample docker
  15. ARG O3DE_REPO=https://github.com/o3de/o3de.git
  16. ARG O3DE_BRANCH=2310.1
  17. ARG O3DE_EXTRAS_REPO=https://github.com/o3de/o3de-extras.git
  18. ARG O3DE_EXTRAS_BRANCH=2310.1
  19. ARG LOFT_GEM_REPO=https://github.com/o3de/loft-arch-vis-sample.git
  20. ARG LOFT_GEM_BRANCH=main
  21. ARG ROBOT_VAC_SAMPLE_REPO=https://github.com/o3de/RobotVacuumSample.git
  22. ARG ROBOT_VAC_SAMPLE_BRANCH=main
  23. # Additional argument to control build concurrency
  24. ARG CMAKE_JOBS=8
  25. ENV WORKSPACE=/data/workspace
  26. WORKDIR $WORKSPACE
  27. RUN apt-get update && apt-get upgrade -y
  28. # Add additional package repositories needed for packages
  29. RUN apt-get install -y --no-install-recommends gpg wget curl
  30. # For ubuntu 20.04 (focal) then default version of cmake is not supported. Update and get version 3.24.1 from kitware
  31. RUN if [ "${UBUNTU_VERSION}" = "focal" ]; then \
  32. wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
  33. gpg --dearmor - | \
  34. tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \
  35. && echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | \
  36. tee /etc/apt/sources.list.d/kitware.list >/dev/null \
  37. && apt-get update; \
  38. fi
  39. #
  40. # Install packages needed for cloning and building from the source repos
  41. #
  42. # Install the git and build tools
  43. RUN apt-get install -y --no-install-recommends git \
  44. git-lfs \
  45. clang-12 \
  46. ninja-build \
  47. cmake \
  48. libglu1-mesa-dev \
  49. libxcb-xinerama0 \
  50. libxcb-xinput0 \
  51. libxcb-xinput-dev \
  52. libxcb-xfixes0-dev \
  53. libxcb-xkb-dev \
  54. libxkbcommon-dev \
  55. libxkbcommon-x11-dev \
  56. libfontconfig1-dev \
  57. libcurl4-openssl-dev \
  58. libsdl2-dev \
  59. zlib1g-dev \
  60. mesa-common-dev \
  61. libssl-dev libxcb-icccm4 \
  62. libxcb-image0 \
  63. libxcb-keysyms1 \
  64. libxcb-render-util0 \
  65. libxcb-randr0 \
  66. libnvidia-gl-470 \
  67. ufw \
  68. ros-${ROS_DISTRO}-slam-toolbox \
  69. ros-${ROS_DISTRO}-navigation2 \
  70. ros-${ROS_DISTRO}-nav2-bringup \
  71. ros-${ROS_DISTRO}-pointcloud-to-laserscan \
  72. ros-${ROS_DISTRO}-gazebo-msgs \
  73. ros-${ROS_DISTRO}-ackermann-msgs \
  74. ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
  75. ros-${ROS_DISTRO}-control-toolbox \
  76. ros-${ROS_DISTRO}-nav-msgs
  77. COPY cleanup.bash /data/workspace/cleanup.bash
  78. # Clone O3DE repos, register, build, and cleanup in the same layer to reduce the size
  79. RUN if [ "${IMAGE_TYPE}" = "simulation" ]; then \
  80. apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-desktop && \
  81. cd $WORKSPACE && \
  82. git clone $O3DE_REPO && \
  83. git -C $WORKSPACE/o3de checkout $O3DE_BRANCH &&\
  84. git -C $WORKSPACE/o3de lfs install && \
  85. git -C $WORKSPACE/o3de lfs pull && \
  86. $WORKSPACE/o3de/python/get_python.sh && \
  87. $WORKSPACE/o3de/scripts/o3de.sh register -ep $WORKSPACE/o3de && \
  88. git clone $O3DE_EXTRAS_REPO && \
  89. git -C $WORKSPACE/o3de-extras checkout $O3DE_EXTRAS_BRANCH &&\
  90. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/ROS2 && \
  91. git clone $LOFT_GEM_REPO && \
  92. git -C $WORKSPACE/loft-arch-vis-sample checkout $LOFT_GEM_BRANCH &&\
  93. git -C $WORKSPACE/loft-arch-vis-sample lfs install && \
  94. git -C $WORKSPACE/loft-arch-vis-sample lfs pull && \
  95. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/loft-arch-vis-sample/Gems/ArchVis/ && \
  96. git clone $ROBOT_VAC_SAMPLE_REPO && \
  97. git -C $WORKSPACE/RobotVacuumSample checkout $ROBOT_VAC_SAMPLE_BRANCH &&\
  98. git -C $WORKSPACE/RobotVacuumSample lfs install && \
  99. git -C $WORKSPACE/RobotVacuumSample lfs pull && \
  100. $WORKSPACE/o3de/scripts/o3de.sh register -pp $WORKSPACE/RobotVacuumSample/ && \
  101. . /opt/ros/${ROS_VERSION}/setup.sh && \
  102. cmake -B $WORKSPACE/RobotVacuumSample/build/linux -S $WORKSPACE/RobotVacuumSample -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON && \
  103. cmake --build $WORKSPACE/RobotVacuumSample/build/linux --config profile --target AssetProcessorBatch RobotVacuumSample.GameLauncher RobotVacuumSample.Assets -j $CMAKE_JOBS && \
  104. $WORKSPACE/cleanup.bash; \
  105. elif [ "${IMAGE_TYPE}" = "navstack" ]; then \
  106. apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-desktop && \
  107. cd $WORKSPACE && \
  108. git clone --recursive $ROBOT_VAC_SAMPLE_REPO && \
  109. git -C $WORKSPACE/RobotVacuumSample checkout $ROBOT_VAC_SAMPLE_BRANCH; \
  110. else \
  111. echo "Unsupported IMAGE_TYPE: ${IMAGE_TYPE}" && exit 1; \
  112. fi
  113. COPY LaunchSimulation.bash /data/workspace/LaunchSimulation.bash
  114. COPY LaunchNavStack.bash /data/workspace/LaunchNavStack.bash
  115. ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
  116. ENV LAUNCH_FULLSCREEN_OPT=0
  117. ENV NVIDIA_VISIBLE_DEVICES all
  118. ENV NVIDIA_DRIVER_CAPABILITIES all
  119. ENTRYPOINT ["/bin/bash", "-c"]