@@ -18,6 +18,7 @@ RUN apt-get -q update \
1818 clang-tools \
1919 python3-pip \
2020 python3-dev \
21+ python3-venv \
2122 lsb-release \
2223 wget \
2324 gnupg \
@@ -38,14 +39,14 @@ RUN apt-get -q update \
3839
3940FROM ci as robot
4041
41- # Configure a new non-root user
42- ARG USERNAME=blue
42+ #
43+ # Ubuntu 24.04 "Noble", which is used as the base image for
44+ # jazzy and rolling images, now includes a user "ubuntu" at UID 1000
45+ ARG USERNAME=ubuntu
4346ARG USER_UID=1000
4447ARG USER_GID=$USER_UID
4548
46- RUN groupadd --gid $USER_GID $USERNAME \
47- && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
48- && echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
49+ RUN echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
4950 && chmod 0440 /etc/sudoers.d/$USERNAME \
5051 && usermod -a -G dialout $USERNAME \
5152 && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
@@ -56,6 +57,16 @@ ENV DEBIAN_FRONTEND=noninteractive
5657USER $USERNAME
5758ENV USER=$USERNAME
5859
60+ # Python in Ubuntu is now marked as a "Externally managed environment",
61+ # Per best practice, create a venv for local python packages
62+ #
63+ # These two ENVs effectively "activate" the venv for subsequent calls to
64+ # python/pip in the Dockerfile
65+ WORKDIR /home/$USERNAME
66+ ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
67+ RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
68+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
69+
5970# Install MAVROS dependencies
6071WORKDIR /home/$USERNAME
6172RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
@@ -85,6 +96,29 @@ RUN sudo apt-get -q update \
8596 && sudo apt-get clean -y \
8697 && sudo rm -rf /var/lib/apt/lists/*
8798
99+ <<<<<<< HEAD
100+ =======
101+ # Manually install MAVROS from source in the ws_blue/ workspace
102+ WORKDIR $USER_WORKSPACE/src/
103+ ARG MAVROS_RELEASE=ros2
104+ ARG MAVLINK_RELEASE=release/rolling/mavlink
105+ RUN git clone --depth 1 -b ${MAVROS_RELEASE} https://github.com/mavlink/mavros.git
106+ RUN git clone --depth 1 --recursive -b ${MAVLINK_RELEASE} https://github.com/mavlink/mavlink-gbp-release.git mavlink
107+ # - mavgen uses future.standard_library for backwards compatibility with Python2;
108+ # However, this caused issues with Python 3.12 installed in "noble".
109+ # Comment those lines out in mavlink.
110+ #
111+ # - Fix linkage for yaml-cpp in mavros_extra_plugins
112+ RUN sed -i -e 's/^from future import standard_library/#from future import standard_library/' \
113+ -e 's/standard_library.install_aliases()/#standard_library.install_aliases()/' \
114+ mavlink/pymavlink/generator/mavgen.py && \
115+ sed -i -e 's/^# find_package(yaml_cpp REQUIRED)/find_package(yaml-cpp REQUIRED)/' \
116+ -e '/^ament_target_dependencies(mavros_extras_plugins$/i target_link_libraries(mavros_extras_plugins yaml-cpp::yaml-cpp)' \
117+ -e '/^ament_target_dependencies(mavros_extras$/i target_link_libraries(mavros_extras yaml-cpp::yaml-cpp)' \
118+ mavros/mavros_extras/CMakeLists.txt
119+
120+ WORKDIR $USER_WORKSPACE
121+ >>>>>>> fe3861d (Rolling ROS image is now based on "noble" (#220))
88122RUN sudo apt-get -q update \
89123 && sudo apt-get -q -y upgrade \
90124 && rosdep update \
@@ -94,13 +128,16 @@ RUN sudo apt-get -q update \
94128 && sudo rm -rf /var/lib/apt/lists/*
95129
96130RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
97- && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc
131+ && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
132+ && echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
133+ && echo "\n # Ensure colcon is run in the venv\n alias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
98134
99135FROM robot as desktop
100136
101137ENV DEBIAN_FRONTEND=noninteractive
102138ENV GZ_VERSION=garden
103139
140+ <<<<<<< HEAD
104141# Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu
105142RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
106143 && 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 \
@@ -115,6 +152,21 @@ RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrin
115152RUN sudo apt-get -q update \
116153 && sudo apt-get -q -y upgrade \
117154 && sudo apt-get -q install --no-install-recommends -y \
155+ =======
156+ # Install Gazebo Harmonic: https://gazebosim.org/docs/harmonic/install_ubuntu
157+ # Per DL3004, use "USER root" rather than "sudo"
158+ # https://github.com/hadolint/hadolint/wiki/DL3004
159+ USER root
160+ # Install custom rosdep list
161+ ADD --chown=root:root --chmod=0644 https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
162+ RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
163+ && 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" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
164+ && apt-get -q update \
165+ && apt-get -y --quiet --no-install-recommends install \
166+ cppzmq-dev \
167+ gz-${GZ_VERSION} \
168+ python3-pexpect \
169+ >>>>>>> fe3861d (Rolling ROS image is now based on "noble" (#220))
118170 python3-wxgtk4.0 \
119171 rapidjson-dev \
120172 xterm \
@@ -132,7 +184,12 @@ RUN git clone https://github.com/ArduPilot/ardupilot.git --recurse-submodules
132184# Install ArduSub dependencies
133185WORKDIR /home/$USERNAME/ardupilot
134186ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
135- RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
187+ # Do not install the STM development tools
188+ ENV DO_AP_STM_ENV=0
189+ # Do not activate the Ardupilot venv by default
190+ ENV DO_PYTHON_VENV_ENV=0
191+ RUN echo "\n # Below from ardupilot script \" install-prereqs-ubuntu.sh\"\n " >> /home/$USERNAME/.bashrc && \
192+ Tools/environment_install/install-prereqs-ubuntu.sh -y
136193
137194# Build ArduSub
138195WORKDIR /home/$USERNAME/ardupilot
0 commit comments