|
1 | 1 | ARG ROS_DISTRO=humble |
2 | | -FROM ros:${ROS_DISTRO} AS deps |
| 2 | +FROM ros:${ROS_DISTRO}-ros-core AS deps |
| 3 | + |
| 4 | +# Install system dependencies early for better caching |
| 5 | +RUN apt update && apt install -y --no-install-recommends \ |
| 6 | + git \ |
| 7 | + build-essential \ |
| 8 | + python3-pip \ |
| 9 | + python3-rosdep \ |
| 10 | + python3-colcon-common-extensions \ |
| 11 | + && rm -rf /var/lib/apt/lists/* |
3 | 12 |
|
4 | 13 | # Create ros2_ws and copy files |
5 | 14 | WORKDIR /root/ros2_ws |
6 | | -SHELL ["/bin/bash", "-c"] |
7 | 15 | COPY . /root/ros2_ws/src |
8 | 16 |
|
9 | | -# Install dependencies |
10 | | -RUN apt-get update |
11 | | -RUN apt-get -y --quiet --no-install-recommends install python3 python3-pip |
12 | | -RUN rosdep install --from-paths src --ignore-src -r -y |
| 17 | +# Install ROS dependencies |
| 18 | +RUN rosdep init && rosdep update --include-eol-distros |
| 19 | +RUN apt update && rosdep install --from-paths src --ignore-src -r -y && rm -rf /var/lib/apt/lists/* |
13 | 20 |
|
14 | | -RUN if [ "$(lsb_release -rs)" = "24.04" ] || [ "$(lsb_release -rs)" = "24.10" ]; then \ |
15 | | - pip3 install -r src/requirements.txt --break-system-packages --ignore-installed; \ |
| 21 | +# Install Python packages |
| 22 | +RUN if [ "$(lsb_release -rs | cut -d. -f1)" -ge 24 ]; then \ |
| 23 | + pip3 install -r src/requirements.txt --break-system-packages --ignore-installed --no-cache-dir; \ |
16 | 24 | else \ |
17 | | - pip3 install -r src/requirements.txt; \ |
| 25 | + pip3 install -r src/requirements.txt --no-cache-dir; \ |
18 | 26 | fi |
19 | 27 |
|
20 | | -# Build the ws with colcon |
21 | 28 | FROM deps AS builder |
22 | | -ARG CMAKE_BUILD_TYPE=Release |
| 29 | + |
| 30 | +SHELL ["/bin/bash", "-c"] |
| 31 | + |
| 32 | +# Build the workspace |
23 | 33 | RUN source /opt/ros/${ROS_DISTRO}/setup.bash && colcon build |
24 | 34 |
|
25 | 35 | # Source the ROS 2 setup file |
|
0 commit comments