Skip to content

Commit 01720cb

Browse files
committed
Adds intermediate "*_unbuilt" stages to support cases where we will bind-mount and rebuild anyway.
1 parent 2a2296c commit 01720cb

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

.docker/Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ RUN apt-get -q update \
4646
# - Installing blue deps using pip, apt and rosdep
4747
# - Installs the remaining blue dependencies from blue_robot.repos
4848
# - Installs deps from rosdep for all src dependencies
49-
# - colcon build
5049
#
51-
FROM ci AS robot
50+
# robot_unbuilt **does not** colcon build, to save time
51+
#
52+
FROM ci AS robot_unbuilt
5253

5354
#
5455
# Ubuntu 24.04 "Noble", which is used as the base image for
@@ -135,11 +136,14 @@ RUN echo "if [ -f ${USER_WORKSPACE}/install/setup.bash ]; then source ${USER_WOR
135136
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
136137
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
137138

139+
# Finally, build
140+
FROM robot_unbuilt AS robot
138141

139142
# Actually build workspace
140143
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
141144
&& colcon build
142145

146+
FROM robot_unbuilt AS desktop_unbuilt
143147

144148
ENV DEBIAN_FRONTEND=noninteractive
145149
ENV GZ_VERSION=harmonic
@@ -216,12 +220,6 @@ RUN sudo apt-get -q update \
216220
&& sudo apt-get clean -y \
217221
&& sudo rm -rf /var/lib/apt/lists/*
218222

219-
# For users that build this on a laptop or system with limited RAM,
220-
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
221-
# This will limit the amount of RAM that colcon is allowed to use
222-
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
223-
&& colcon build
224-
225223
# Setup the simulation environment variables
226224
RUN <<EOT cat >> /home/$USERNAME/.bashrc
227225

@@ -238,6 +236,15 @@ export GZ_SIM_SYSTEM_PLUGIN_PATH=\$HOME/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_P
238236
export GZ_SIM_RESOURCE_PATH=\$HOME/ardupilot_gazebo/models:\$HOME/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH
239237
EOT
240238

239+
240+
FROM desktop_unbuilt AS desktop
241+
242+
# For users that build this on a laptop or system with limited RAM,
243+
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
244+
# This will limit the amount of RAM that colcon is allowed to use
245+
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
246+
&& colcon build
247+
241248
FROM desktop AS desktop-nvidia
242249

243250
# 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)