Dockerfile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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=jazzy
  7. FROM ros:${ROS_VERSION}-ros-base
  8. # Argument to determining the image type ('simulation' or 'navstack')
  9. ARG IMAGE_TYPE=simulation # Default to 'simulation'
  10. # Arguments for the source repos needed for the Ros2Template sample docker
  11. ARG O3DE_REPO=https://github.com/o3de/o3de.git
  12. ARG O3DE_BRANCH=main
  13. ARG O3DE_EXTRAS_REPO=https://github.com/o3de/o3de-extras.git
  14. ARG O3DE_EXTRAS_BRANCH=main
  15. # Additional argument to control build concurrency
  16. ARG CMAKE_JOBS=8
  17. ENV WORKSPACE=/data/workspace
  18. ENV PROJECT_PATH=/data/workspace/Ros2Project
  19. WORKDIR $WORKSPACE
  20. RUN apt-get update && apt-get upgrade -y
  21. # Install packages needed for cloning and building from the source repos
  22. RUN apt-get install -y --no-install-recommends \
  23. git \
  24. git-lfs \
  25. clang \
  26. ninja-build \
  27. cmake \
  28. libglu1-mesa-dev \
  29. libxcb-xinerama0 \
  30. libxcb-xinput0 \
  31. libxcb-xinput-dev \
  32. libxcb-xfixes0-dev \
  33. libxcb-xkb-dev \
  34. libxkbcommon-dev \
  35. libxkbcommon-x11-dev \
  36. libfontconfig1-dev \
  37. libcurl4-openssl-dev \
  38. libsdl2-dev \
  39. zlib1g-dev \
  40. mesa-common-dev \
  41. libssl-dev libxcb-icccm4 \
  42. libxcb-image0 \
  43. libxcb-keysyms1 \
  44. libxcb-render-util0 \
  45. libxcb-randr0 \
  46. libnvidia-gl-470 \
  47. ufw \
  48. ros-${ROS_DISTRO}-slam-toolbox \
  49. ros-${ROS_DISTRO}-navigation2 \
  50. ros-${ROS_DISTRO}-nav2-bringup \
  51. ros-${ROS_DISTRO}-pointcloud-to-laserscan \
  52. ros-${ROS_DISTRO}-gazebo-msgs \
  53. ros-${ROS_DISTRO}-ackermann-msgs \
  54. ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
  55. ros-${ROS_DISTRO}-control-toolbox \
  56. ros-${ROS_DISTRO}-nav-msgs \
  57. ros-${ROS_DISTRO}-desktop
  58. # Copy script used to remove build artifacts
  59. COPY cleanup.bash /data/workspace/cleanup.bash
  60. # Clone and register O3DE repos
  61. RUN if [ "${IMAGE_TYPE}" = "simulation" ]; then \
  62. cd $WORKSPACE && \
  63. git clone --recursive $O3DE_REPO && \
  64. git -C $WORKSPACE/o3de checkout $O3DE_BRANCH &&\
  65. git -C $WORKSPACE/o3de lfs install && \
  66. git -C $WORKSPACE/o3de lfs pull && \
  67. $WORKSPACE/o3de/python/get_python.sh && \
  68. $WORKSPACE/o3de/scripts/o3de.sh register -ep $WORKSPACE/o3de && \
  69. git clone $O3DE_EXTRAS_REPO && \
  70. git -C $WORKSPACE/o3de-extras checkout $O3DE_EXTRAS_BRANCH && \
  71. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/ROS2 && \
  72. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/RosRobotSample && \
  73. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/WarehouseAssets && \
  74. $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-extras/Gems/WarehouseSample; \
  75. elif [ "${IMAGE_TYPE}" = "navstack" ]; then \
  76. cd $WORKSPACE && \
  77. git clone $O3DE_EXTRAS_REPO && \
  78. git -C $WORKSPACE/o3de-extras checkout $O3DE_EXTRAS_BRANCH; \
  79. else \
  80. echo "Unsupported IMAGE_TYPE: ${IMAGE_TYPE}" && exit 1; \
  81. fi
  82. # Build and cleanup in the same layer to reduce the size
  83. RUN if [ "${IMAGE_TYPE}" = "simulation" ]; then \
  84. . /opt/ros/${ROS_DISTRO}/setup.sh && \
  85. $WORKSPACE/o3de/scripts/o3de.sh create-project --project-path $PROJECT_PATH --template-path $WORKSPACE/o3de-extras/Templates/Ros2ProjectTemplate && \
  86. cmake -B $PROJECT_PATH/build/linux -S $PROJECT_PATH -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON && \
  87. cmake --build $PROJECT_PATH/build/linux --config profile --target Ros2Project Editor Ros2Project.Assets Ros2Project.GameLauncher -j $CMAKE_JOBS && \
  88. $WORKSPACE/cleanup.bash ; \
  89. fi
  90. COPY LaunchSimulation.bash /data/workspace/LaunchSimulation.bash
  91. COPY LaunchNavStack.bash /data/workspace/LaunchNavStack.bash
  92. ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
  93. ENV LAUNCH_FULLSCREEN_OPT=0
  94. ENV NVIDIA_VISIBLE_DEVICES all
  95. ENV NVIDIA_DRIVER_CAPABILITIES all
  96. ENTRYPOINT ["/bin/bash"]