content: ##############################################
  # Created from template ros2.dockerfile.jinja
  ##############################################
  
  ###########################################
  # Base image
  ###########################################
  FROM nvidia/cuda:13.0.1-cudnn-runtime-ubuntu24.04 AS base
  
  ENV DEBIAN_FRONTEND=noninteractive
  
  # Install language
  RUN apt-get update && apt-get install -y --no-install-recommends \
    locales \
    && locale-gen en_US.UTF-8 \
    && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
    && rm -rf /var/lib/apt/lists/*
  ENV LANG=en_US.UTF-8
  
  # Install timezone
  RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime \
    && export DEBIAN_FRONTEND=noninteractive \
    && apt-get update \
    && apt-get install -y --no-install-recommends tzdata \
    && dpkg-reconfigure --frontend noninteractive tzdata \
    && rm -rf /var/lib/apt/lists/*
  
  RUN apt-get update && apt-get -y upgrade \
      && rm -rf /var/lib/apt/lists/*
  
  # Install common programs
  RUN apt-get update && apt-get install -y --no-install-recommends \
      curl \
      gnupg2 \
      lsb-release \
      sudo \
      software-properties-common \
      wget \
      && rm -rf /var/lib/apt/lists/*
  
  # Setup ROS Apt sources
  RUN curl -L -s -o /tmp/ros2-apt-source.deb https://github.com/ros-infrastructure/ros-apt-source/releases/download/1.1.0/ros2-apt-source_1.1.0.$(lsb_release -cs)_all.deb \
      && apt-get update \
      && apt-get install /tmp/ros2-apt-source.deb \
      && rm -f /tmp/ros2-apt-source.deb \
      && rm -rf /var/lib/apt/lists/*
  
  ENV ROS_DISTRO=jazzy
  
  # Install ROS2
  RUN apt-get update && apt-get install -y --no-install-recommends \
      ros-jazzy-ros-base \
      python3-argcomplete \
      python3-rosdep \
    && rm -rf /var/lib/apt/lists/*
  
  ################
  # Expose the nvidia driver to allow opengl
  # Dependencies for glvnd and X11.
  ################
  RUN apt-get update \
   && apt-get install -y -qq --no-install-recommends \
    libglvnd0 \
    libgl1 \
    libglx0 \
    libegl1 \
    libxext6 \
    libx11-6
  
  # Env vars for the nvidia-container-runtime.
  ENV NVIDIA_VISIBLE_DEVICES=all
  ENV NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute
  ENV QT_X11_NO_MITSHM=1
  ENV DEBIAN_FRONTEND=
  
  # setup entrypoint
  COPY ./ros_entrypoint.sh /
  
  ENTRYPOINT ["/ros_entrypoint.sh"]
  CMD ["bash"]
  ###########################################
  #  Develop image
  ###########################################
  FROM base AS dev
  
  ENV DEBIAN_FRONTEND=noninteractive
  RUN apt-get update && apt-get install -y --no-install-recommends \
    bash-completion \
    build-essential \
    cmake \
    gdb \
    git \
    openssh-client \
    python3-argcomplete \
    python3-pip \
    ros-dev-tools \
    ros-jazzy-ament-* \
    vim \
    && rm -rf /var/lib/apt/lists/*
  
  RUN rosdep init || echo "rosdep already initialized"
  
  ARG USERNAME=ros
  ARG USER_UID=1000
  ARG USER_GID=$USER_UID
  
  # Check if "ubuntu" user exists, delete it if it does, then create the desired user
  RUN if getent passwd ubuntu > /dev/null 2>&1; then \
          userdel -r ubuntu && \
          echo "Deleted existing ubuntu user"; \
      fi && \
      groupadd --gid $USER_GID $USERNAME && \
      useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME && \
      echo "Created new user $USERNAME"
  
  # Add sudo support for the non-root user
  RUN apt-get update && apt-get install -y sudo \
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    && rm -rf /var/lib/apt/lists/*
  
  # Set up autocompletion for user
  RUN apt-get update && apt-get install -y --no-install-recommends git-core bash-completion \
    && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc \
    && echo "if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash; fi" >> /home/$USERNAME/.bashrc \
    && rm -rf /var/lib/apt/lists/*
  
  ENV DEBIAN_FRONTEND=
  ENV AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1
  
  ###########################################
  #  Full image
  ###########################################
  FROM dev AS full
  
  ENV DEBIAN_FRONTEND=noninteractive
  # Install the full release
  RUN apt-get update && apt-get install -y --no-install-recommends \
    ros-jazzy-desktop \
    && rm -rf /var/lib/apt/lists/*
  ENV DEBIAN_FRONTEND=
  
  
  ###########################################
  #  Full+Gazebo image
  ###########################################
  FROM full AS gazebo
  
  ENV DEBIAN_FRONTEND=noninteractive
  # Install gazebo
  RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
    && apt-get update && apt-get install -q -y --no-install-recommends \
      ros-jazzy-ros-gz \
    && rm -rf /var/lib/apt/lists/*
  ENV DEBIAN_FRONTEND=