Преглед на файлове

- Update Dockerscripts to optimize size by reducing the number of layers
- Update README.md instructions

Signed-off-by: Steve Pham <[email protected]>

Steve Pham преди 2 години
родител
ревизия
7df3353aa2
променени са 4 файла, в които са добавени 57 реда и са изтрити 103 реда
  1. 30 46
      Docker/Dockerfile.simulation.ubuntu-galactic
  2. 25 55
      Docker/Dockerfile.simulation.ubuntu-humble
  3. 2 2
      Docker/README.md
  4. 0 0
      Docker/cleanup.bash

+ 30 - 46
Docker/Dockerfile.simulation.ubuntu-galactic

@@ -5,15 +5,21 @@
 #
 #
 
 
 FROM ros:galactic-ros-base-focal
 FROM ros:galactic-ros-base-focal
-ARG minimal
+
 ENV WORKSPACE=/data/workspace
 ENV WORKSPACE=/data/workspace
+
 ENV O3DE_REPO=https://github.com/o3de/o3de.git
 ENV O3DE_REPO=https://github.com/o3de/o3de.git
 ENV ROS2_GEM_REPO=https://github.com/RobotecAI/o3de-ros2-gem.git
 ENV ROS2_GEM_REPO=https://github.com/RobotecAI/o3de-ros2-gem.git
 ENV LOFT_GEM_REPO=https://github.com/o3de/loft-arch-vis-sample.git
 ENV LOFT_GEM_REPO=https://github.com/o3de/loft-arch-vis-sample.git
 ENV O3DE_DEMO_REPO=https://github.com/RobotecAI/o3de-demo-project.git
 ENV O3DE_DEMO_REPO=https://github.com/RobotecAI/o3de-demo-project.git
 
 
+ENV ROS2_DISTRO=galactic
+
 WORKDIR $WORKSPACE
 WORKDIR $WORKSPACE
 
 
+COPY LaunchClient.bash.ubuntu-galactic /data/workspace/LaunchClient.bash
+COPY cleanup.bash /data/workspace/cleanup.bash
+
 RUN apt-get update && apt-get upgrade -y
 RUN apt-get update && apt-get upgrade -y
 
 
 # Add additional package repositories needed for packages
 # Add additional package repositories needed for packages
@@ -34,10 +40,8 @@ RUN apt-get install -y --no-install-recommends git \
                        git-lfs \
                        git-lfs \
                        cmake=3.24.1-0kitware1ubuntu20.04.1 \
                        cmake=3.24.1-0kitware1ubuntu20.04.1 \
                        clang-12 \
                        clang-12 \
-                       ninja-build
-
-# Install the O3DE-specific required packages
-RUN apt-get install -y --no-install-recommends libglu1-mesa-dev \
+                       ninja-build \
+                       libglu1-mesa-dev \
                        libxcb-xinerama0 \
                        libxcb-xinerama0 \
                        libxcb-xinput0 \
                        libxcb-xinput0 \
                        libxcb-xinput-dev \
                        libxcb-xinput-dev \
@@ -58,24 +62,6 @@ RUN apt-get install -y --no-install-recommends libglu1-mesa-dev \
                        libnvidia-gl-470 \
                        libnvidia-gl-470 \
                        ufw
                        ufw
 
 
-# Clone O3DE repo and register the engine
-RUN cd $WORKSPACE && \
-    git clone --single-branch --recursive --branch development $O3DE_REPO && \
-    cd o3de && \
-    git lfs install && \
-    git lfs pull
-
-RUN cd $WORKSPACE/o3de && \
-    python/get_python.sh
-RUN cd $WORKSPACE/o3de && \
-    $WORKSPACE/o3de/scripts/o3de.sh register --this-engine
-
-
-# Clone the ROS2 Gem and register it
-RUN cd $WORKSPACE && \
-    git clone $ROS2_GEM_REPO --single-branch --branch development && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-ros2-gem
-
 # Add additional ROS2/Galactic packages
 # Add additional ROS2/Galactic packages
 RUN /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
 RUN /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
                   apt install -y ros-${ROS_DISTRO}-slam-toolbox \
                   apt install -y ros-${ROS_DISTRO}-slam-toolbox \
@@ -86,39 +72,37 @@ RUN /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
                                  ros-${ROS_DISTRO}-ackermann-msgs \
                                  ros-${ROS_DISTRO}-ackermann-msgs \
                                  ros-${ROS_DISTRO}-control-toolbox'
                                  ros-${ROS_DISTRO}-control-toolbox'
 
 
-# Clone the loft scene and register the ArchVis Gem
+
+# Clone O3DE repos, register, build, and cleanup in the same layer to reduce the size
 RUN cd $WORKSPACE && \
 RUN cd $WORKSPACE && \
+    git clone --single-branch --recursive --branch development $O3DE_REPO && \
+    cd o3de && \
+    git lfs install && \
+    git lfs pull && \
+    cd $WORKSPACE/o3de && \
+    python/get_python.sh && \
+    cd $WORKSPACE/o3de && \
+    $WORKSPACE/o3de/scripts/o3de.sh register --this-engine && \
+    cd $WORKSPACE && \
+    git clone $ROS2_GEM_REPO --single-branch --branch development && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-ros2-gem && \
     git clone --single-branch --recursive $LOFT_GEM_REPO && \
     git clone --single-branch --recursive $LOFT_GEM_REPO && \
     cd loft-arch-vis-sample && \
     cd loft-arch-vis-sample && \
     git lfs install && \
     git lfs install && \
     git lfs pull && \
     git lfs pull && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/loft-arch-vis-sample/Gems/ArchVis/
-
-
-# Clone the demo project and register the project
-RUN cd $WORKSPACE && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/loft-arch-vis-sample/Gems/ArchVis/ && \
+    cd $WORKSPACE && \
     git clone --single-branch --branch main --recursive $O3DE_DEMO_REPO && \
     git clone --single-branch --branch main --recursive $O3DE_DEMO_REPO && \
     cd o3de-demo-project && \
     cd o3de-demo-project && \
     git lfs install && \
     git lfs install && \
     git lfs pull && \
     git lfs pull && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -pp $WORKSPACE/o3de-demo-project/ 
-
-
-# Configure the project
-RUN cd $WORKSPACE/o3de-demo-project && \
-    /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
-                  cmake -B build/linux -S . -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE=profile -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON'
-
-# Build the project
-RUN cd $WORKSPACE/o3de-demo-project && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -pp $WORKSPACE/o3de-demo-project/  && \
+    cd $WORKSPACE/o3de-demo-project && \
     /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
     /bin/bash -c 'source /opt/ros/galactic/setup.bash && \
-                  cmake --build build/linux --config profile --target AssetProcessorBatch ROS2-Gem-Demo.GameLauncher ROS2-Gem-Demo.Assets -j 12'
-
-
-COPY LaunchClient.bash.ubuntu-galactic /data/workspace/LaunchClient.bash
-COPY delete_source.bash /data/workspace/delete_source.bash
-
-RUN if [ "$minimal" -eq "1" ]; then /bin/bash -c 'source /data/workspace/delete_source.bash'; else echo "Skipping source delete"; fi
+                  cmake -B build/linux -S . -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON && \
+                  cmake --build build/linux --config profile --target AssetProcessorBatch ROS2-Gem-Demo.GameLauncher ROS2-Gem-Demo.Assets -j 12 && \
+                  cd $WORKSPACE && \
+                  ./cleanup.bash'
  
  
 ENV NVIDIA_VISIBLE_DEVICES all
 ENV NVIDIA_VISIBLE_DEVICES all
 ENV NVIDIA_DRIVER_CAPABILITIES all
 ENV NVIDIA_DRIVER_CAPABILITIES all

+ 25 - 55
Docker/Dockerfile.simulation.ubuntu-humble

@@ -16,22 +16,14 @@ ENV O3DE_DEMO_REPO=https://github.com/RobotecAI/o3de-demo-project.git
 
 
 WORKDIR $WORKSPACE
 WORKDIR $WORKSPACE
 
 
+COPY LaunchClient.bash.ubuntu-humble /data/workspace/LaunchClient.bash
+COPY cleanup.bash /data/workspace/cleanup.bash
+
 RUN apt-get update && apt-get upgrade -y
 RUN apt-get update && apt-get upgrade -y
 
 
 # Add additional package repositories needed for packages
 # Add additional package repositories needed for packages
 RUN apt-get install -y --no-install-recommends gpg wget curl build-essential libssl-dev
 RUN apt-get install -y --no-install-recommends gpg wget curl build-essential libssl-dev
 
 
-# Build and install cmake 3.24.3 from source since the default cmake version of ubuntu focal does not meet it
-RUN cd /data/workspace && \
-    wget -c https://github.com/Kitware/CMake/archive/refs/tags/v3.24.3.tar.gz && \
-    wget -c https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3.tar.gz && \
-    tar -zxvf cmake-3.24.3.tar.gz && \
-    cd cmake-3.24.3 && \
-    ./bootstrap && \
-    make && \
-    make install && \
-    cmake --version
-
 #
 #
 # Install packages needed for cloning and building from the source repos
 # Install packages needed for cloning and building from the source repos
 #
 #
@@ -40,10 +32,8 @@ RUN cd /data/workspace && \
 RUN apt-get install -y --no-install-recommends git \
 RUN apt-get install -y --no-install-recommends git \
                        git-lfs \
                        git-lfs \
                        clang-12 \
                        clang-12 \
-                       ninja-build
-
-# Install the O3DE-specific required packages
-RUN apt-get install -y --no-install-recommends libglu1-mesa-dev \
+                       ninja-build \
+                       libglu1-mesa-dev \
                        libxcb-xinerama0 \
                        libxcb-xinerama0 \
                        libxcb-xinput0 \
                        libxcb-xinput0 \
                        libxcb-xinput-dev \
                        libxcb-xinput-dev \
@@ -64,24 +54,6 @@ RUN apt-get install -y --no-install-recommends libglu1-mesa-dev \
                        libnvidia-gl-470 \
                        libnvidia-gl-470 \
                        ufw
                        ufw
 
 
-# Clone O3DE repo and register the engine
-RUN cd $WORKSPACE && \
-    git clone --single-branch --recursive --branch development $O3DE_REPO && \
-    cd o3de && \
-    git lfs install && \
-    git lfs pull
-
-RUN cd $WORKSPACE/o3de && \
-    python/get_python.sh
-RUN cd $WORKSPACE/o3de && \
-    $WORKSPACE/o3de/scripts/o3de.sh register --this-engine
-
-
-# Clone the ROS2 Gem and register it
-RUN cd $WORKSPACE && \
-    git clone $ROS2_GEM_REPO --single-branch --branch development && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-ros2-gem
-
 # Add additional ROS2/Galactic packages
 # Add additional ROS2/Galactic packages
 RUN /bin/bash -c 'source /opt/ros/humble/setup.bash && \
 RUN /bin/bash -c 'source /opt/ros/humble/setup.bash && \
                   apt install -y ros-${ROS_DISTRO}-slam-toolbox \
                   apt install -y ros-${ROS_DISTRO}-slam-toolbox \
@@ -92,39 +64,37 @@ RUN /bin/bash -c 'source /opt/ros/humble/setup.bash && \
                                  ros-${ROS_DISTRO}-ackermann-msgs \
                                  ros-${ROS_DISTRO}-ackermann-msgs \
                                  ros-${ROS_DISTRO}-control-toolbox'
                                  ros-${ROS_DISTRO}-control-toolbox'
 
 
-# Clone the loft scene and register the ArchVis Gem
+# Clone O3DE repos, register, build, and cleanup in the same layer to reduce the size
 RUN cd $WORKSPACE && \
 RUN cd $WORKSPACE && \
+    git clone --single-branch --recursive --branch development $O3DE_REPO && \
+    cd o3de && \
+    git lfs install && \
+    git lfs pull && \
+    cd $WORKSPACE/o3de && \
+    python/get_python.sh && \
+    cd $WORKSPACE/o3de && \
+    $WORKSPACE/o3de/scripts/o3de.sh register --this-engine && \
+    cd $WORKSPACE && \
+    git clone $ROS2_GEM_REPO --single-branch --branch development && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/o3de-ros2-gem && \
     git clone --single-branch --recursive $LOFT_GEM_REPO && \
     git clone --single-branch --recursive $LOFT_GEM_REPO && \
     cd loft-arch-vis-sample && \
     cd loft-arch-vis-sample && \
     git lfs install && \
     git lfs install && \
     git lfs pull && \
     git lfs pull && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/loft-arch-vis-sample/Gems/ArchVis/
-
-
-# Clone the demo project and register the project
-RUN cd $WORKSPACE && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -gp $WORKSPACE/loft-arch-vis-sample/Gems/ArchVis/ && \
+    cd $WORKSPACE && \
     git clone --single-branch --branch main --recursive $O3DE_DEMO_REPO && \
     git clone --single-branch --branch main --recursive $O3DE_DEMO_REPO && \
     cd o3de-demo-project && \
     cd o3de-demo-project && \
     git lfs install && \
     git lfs install && \
     git lfs pull && \
     git lfs pull && \
-    $WORKSPACE/o3de/scripts/o3de.sh register -pp $WORKSPACE/o3de-demo-project/ 
-
-
-# Configure the project
-RUN cd $WORKSPACE/o3de-demo-project && \
-    /bin/bash -c 'source /opt/ros/humble/setup.bash && \
-                  cmake -B build/linux -S . -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE=profile -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON'
-
-# Build the project
-RUN cd $WORKSPACE/o3de-demo-project && \
+    $WORKSPACE/o3de/scripts/o3de.sh register -pp $WORKSPACE/o3de-demo-project/  && \
+    cd $WORKSPACE/o3de-demo-project && \
     /bin/bash -c 'source /opt/ros/humble/setup.bash && \
     /bin/bash -c 'source /opt/ros/humble/setup.bash && \
-                  cmake --build build/linux --config profile --target AssetProcessorBatch ROS2-Gem-Demo.GameLauncher ROS2-Gem-Demo.Assets -j 12'
-
-
-COPY LaunchClient.bash.ubuntu-humble /data/workspace/LaunchClient.bash
-COPY delete_source.bash /data/workspace/delete_source.bash
+                  cmake -B build/linux -S . -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON && \
+                  cmake --build build/linux --config profile --target AssetProcessorBatch ROS2-Gem-Demo.GameLauncher ROS2-Gem-Demo.Assets -j 12 && \
+                  cd $WORKSPACE && \
+                  ./cleanup.bash'
 
 
-RUN if [ "$minimal" -eq "1" ]; then /bin/bash -c 'source /data/workspace/delete_source.bash'; else echo "Skipping source delete"; fi
  
  
 ENV NVIDIA_VISIBLE_DEVICES all
 ENV NVIDIA_VISIBLE_DEVICES all
 ENV NVIDIA_DRIVER_CAPABILITIES all
 ENV NVIDIA_DRIVER_CAPABILITIES all

+ 2 - 2
Docker/README.md

@@ -29,7 +29,7 @@ Select which docker image you would like to build and run the following commands
 
 
 ```
 ```
 
 
-sudo docker build --build-arg minimal=1 -t o3de_loft_demo_simulation:latest -f Dockerfile.simulation.ubuntu-galactic .
+sudo docker build -t o3de_loft_demo_simulation:latest -f Dockerfile.simulation.ubuntu-galactic .
 
 
 sudo docker build -t o3de_loft_demo_robot:latest -f Dockerfile.robot.ubuntu-galactic .
 sudo docker build -t o3de_loft_demo_robot:latest -f Dockerfile.robot.ubuntu-galactic .
 
 
@@ -37,7 +37,7 @@ sudo docker build -t o3de_loft_demo_robot:latest -f Dockerfile.robot.ubuntu-gala
 
 
 ```
 ```
 
 
-sudo docker build --build-arg minimal=1 -t o3de_loft_demo_simulation:latest -f Dockerfile.simulation.ubuntu-humble .
+sudo docker build -t o3de_loft_demo_simulation:latest -f Dockerfile.simulation.ubuntu-humble .
 
 
 sudo docker build -t o3de_loft_demo_robot:latest -f Dockerfile.robot.ubuntu-humble .
 sudo docker build -t o3de_loft_demo_robot:latest -f Dockerfile.robot.ubuntu-humble .
 
 

+ 0 - 0
Docker/delete_source.bash → Docker/cleanup.bash