Skip to content

Commit e26485e

Browse files
committed
Adds intermediate "*_unbuilt" stages to support cases where we will bind-mount and rebuild anyway.
1 parent 86f394e commit e26485e

File tree

2 files changed

+42
-26
lines changed

2 files changed

+42
-26
lines changed

.docker/Dockerfile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ RUN apt-get -q update \
4444
# - Installing blue deps using pip, apt and rosdep
4545
# - Installs the remaining blue dependencies from blue_robot.repos
4646
# - Installs deps from rosdep for all src dependencies
47-
# - colcon build
4847
#
49-
FROM ci AS robot
48+
# robot_unbuilt **does not** colcon build, to save time
49+
#
50+
FROM ci AS robot_unbuilt
5051

5152
#
5253
# Ubuntu 24.04 "Noble", which is used as the base image for
@@ -137,16 +138,19 @@ RUN sudo apt-get -q update \
137138
&& sudo apt-get clean -y \
138139
&& sudo rm -rf /var/lib/apt/lists/*
139140

140-
# Actually build workspace
141-
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
142-
&& colcon build
143-
144-
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
141+
RUN echo "if [ -f ${USER_WORKSPACE}/install/setup.bash ]; then source ${USER_WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \
145142
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
146143
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
147144
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
148145

149-
FROM robot AS desktop
146+
# Finally, build
147+
FROM robot_unbuilt AS robot
148+
149+
# Actually build workspace
150+
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
151+
&& colcon build
152+
153+
FROM robot_unbuilt AS desktop_unbuilt
150154

151155
ENV DEBIAN_FRONTEND=noninteractive
152156
ENV GZ_VERSION=harmonic
@@ -223,12 +227,6 @@ RUN sudo apt-get -q update \
223227
&& sudo apt-get clean -y \
224228
&& sudo rm -rf /var/lib/apt/lists/*
225229

226-
# For users that build this on a laptop or system with limited RAM,
227-
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
228-
# This will limit the amount of RAM that colcon is allowed to use
229-
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
230-
&& colcon build
231-
232230
# Setup the simulation environment variables
233231
RUN <<EOT cat >> /home/$USERNAME/.bashrc
234232

@@ -245,6 +243,15 @@ export GZ_SIM_SYSTEM_PLUGIN_PATH=\$HOME/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_P
245243
export GZ_SIM_RESOURCE_PATH=\$HOME/ardupilot_gazebo/models:\$HOME/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH
246244
EOT
247245

246+
247+
FROM desktop_unbuilt AS desktop
248+
249+
# For users that build this on a laptop or system with limited RAM,
250+
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
251+
# This will limit the amount of RAM that colcon is allowed to use
252+
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
253+
&& colcon build
254+
248255
FROM desktop AS desktop-nvidia
249256

250257
# Install NVIDIA software

.docker/docker-bake.hcl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,39 @@ target "ci" {
5858
platforms = ["linux/amd64", "linux/arm64"]
5959
}
6060

61+
target "robot_unbuilt" {
62+
inherits = [ "ci" ]
63+
target = "robot_unbuilt"
64+
tags = [
65+
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-unbuilt"
66+
]
67+
68+
}
69+
6170
target "robot" {
62-
inherits = [ "ci", "docker-metadata-action-robot" ]
71+
inherits = [ "robot_unbuilt", "docker-metadata-action-robot" ]
6372
target = "robot"
6473
tags = [
6574
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot"
6675
]
67-
cache_to = [
68-
"type=local,dest=.docker-cache"
76+
}
77+
78+
target "desktop_unbuilt" {
79+
inherits = [ "ci" ]
80+
target = "desktop"
81+
tags = [
82+
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-unbuilt"
6983
]
84+
# amd64 only builds for desktop and desktop-nvidia
85+
platforms = ["linux/amd64"]
7086
}
7187

7288
target "desktop" {
73-
inherits = [ "ci", "docker-metadata-action-desktop" ]
89+
inherits = [ "desktop_unbuilt", "docker-metadata-action-desktop" ]
7490
target = "desktop"
7591
tags = [
7692
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop"
7793
]
78-
cache_to = [
79-
"type=local,dest=.docker-cache"
80-
]
81-
# amd64 only builds for desktop and desktop-nvidia
82-
platforms = ["linux/amd64"]
8394
}
8495

8596
target "desktop-nvidia" {
@@ -88,7 +99,5 @@ target "desktop-nvidia" {
8899
tags = [
89100
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia"
90101
]
91-
cache_to = [
92-
"type=local,dest=.docker-cache"
93-
]
102+
94103
}

0 commit comments

Comments
 (0)