Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjay-j-p authored Sep 12, 2024
1 parent c1c3200 commit 215eee2
Showing 1 changed file with 53 additions and 57 deletions.
110 changes: 53 additions & 57 deletions cadre_demo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,40 @@

FROM osrf/space-ros:latest

# Define arguments used in the metadata definition
# Define build arguments and metadata
ARG VCS_REF
ARG VERSION="preview"

# Specify the docker image metadata
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="CADRE demo:Cooperative Autonomous Distributed Robotic Exploration"
LABEL org.label-schema.description="Three small rovers that will work together to explore the Moon for the NASA Space ROS Sim Summer Sprint Challenge"
LABEL org.label-schema.name="CADRE demo: Cooperative Autonomous Distributed Robotic Exploration"
LABEL org.label-schema.description="Three small rovers for NASA Space ROS Sim Summer Sprint Challenge"
LABEL org.label-schema.vendor="Open Robotics"
LABEL org.label-schema.version=${VERSION}
LABEL org.label-schema.url="https://github.com/space-ros"
LABEL org.label-schema.vcs-url="https://github.com/space-ros/docker"
LABEL org.label-schema.vcs-ref=${VCS_REF}

# Disable prompting during package installation
# Disable interactive prompts for package installations
ARG DEBIAN_FRONTEND=noninteractive

# Define a few key variables
# Define environment variables for Classic Gazebo
ENV DEMO_DIR=${HOME_DIR}/demos_ws
ENV IGNITION_VERSION=fortress
ENV GZ_VERSION=fortress

# Clone all space-ros sources
RUN mkdir ${SPACEROS_DIR}/src \
&& vcs import ${SPACEROS_DIR}/src < ${SPACEROS_DIR}/exact.repos

# Define key locations
ENV GAZEBO_VERSION=11 # Use Classic Gazebo 11
ENV GAZEBO_MODEL_PATH=/root/.gazebo/models
ENV GAZEBO_RESOURCE_PATH=/root/.gazebo
ENV GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins
ENV GAZEBO_MASTER_URI=http://localhost:11345
ENV GAZEBO_IP=127.0.0.1
ENV ROS_DISTRO=humble

# Prepare the workspace
RUN mkdir -p ${DEMO_DIR}/src
WORKDIR ${DEMO_DIR}

# Update and upgrade the base system
RUN apt-get update && apt-get dist-upgrade -y

# Make sure the latest versions of packages are installed
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
# the cache won't make it into the built image but will be maintained between steps.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get dist-upgrade -y
RUN rosdep update

# Install the various build and test tools
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt install -y \
# Install ROS dependencies and tools
RUN apt-get install -y \
build-essential \
clang-format \
cmake \
Expand All @@ -81,7 +69,22 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
python3-vcstool \
wget

# Install some pip packages needed for testing
# Install Gazebo 11 (Classic Gazebo) and ROS 2 integration packages
RUN apt-get install -y \
gazebo11 \
libgazebo11-dev \
ros-${ROS_DISTRO}-gazebo-ros-pkgs \
ros-${ROS_DISTRO}-gazebo-ros2-control \
ros-${ROS_DISTRO}-gazebo-ros2-controllers \
ros-${ROS_DISTRO}-robot-state-publisher \
ros-${ROS_DISTRO}-joint-state-publisher \
ros-${ROS_DISTRO}-xacro \
python3-vcstool \
libbullet-dev \
xterm \
vim

# Install Python testing tools
RUN python3 -m pip install -U \
argcomplete \
flake8-blind-except \
Expand All @@ -96,58 +99,51 @@ RUN python3 -m pip install -U \
pytest-rerunfailures \
pytest

# Get rosinstall_generator
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator

# Install rosinstall_generator
RUN apt-get install -y python3-rosinstall-generator

# Generate repos file for dependencies, excluding packages from Space ROS core.
# Generate the repos file for demo dependencies
COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/
COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/
RUN rosinstall_generator \
--upstream \
--rosdistro ${ROSDISTRO} \
--rosdistro ${ROS_DISTRO} \
--deps \
--exclude-path ${SPACEROS_DIR}/src \
--exclude $(cat /tmp/excluded-pkgs.txt) -- \
-- $(cat /tmp/demo-pkgs.txt) \
> /tmp/demo_generated_pkgs.repos

# Import dependencies from the generated repos
RUN vcs import src < /tmp/demo_generated_pkgs.repos

# Get the source for the dependencies
# Import additional manual dependencies
COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/
RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"'
RUN rm -rf ${DEMO_DIR}/src/* && vcs import src < /tmp/demo_manual_pkgs.repos

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get update -y \
&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \
&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO}
# Source ROS setup and install dependencies
RUN apt-get update -y && \
source "/opt/ros/${ROS_DISTRO}/setup.bash" && \
rosdep update && \
rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO}

# Build the demo
ENV MAKEFLAGS="-j1"
RUN /bin/bash -c 'source /opt/ros/${ROS_DISTRO}/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release'

# build demo
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-'


# Add the user to the render group so that the user can access /dev/dri/renderD128
RUN sudo usermod -aG render $USERNAME
# Add the user to the render group for GPU access
RUN usermod -aG render ${USERNAME}

# Add a couple sample GUI apps for testing
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
sudo apt-get install -y \
# Install sample GUI apps for testing
RUN apt-get install -y \
firefox \
glmark2 \
libcanberra-gtk3-0 \
libpci-dev \
xauth \
xterm

# Setup the entrypoint
# Setup entrypoint and run command
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]

0 comments on commit 215eee2

Please sign in to comment.