Skip to content

Inserts "_unbuilt" stages into the Docker file #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ RUN apt-get -q update \
# - Installing blue deps using pip, apt and rosdep
# - Installs the remaining blue dependencies from blue_robot.repos
# - Installs deps from rosdep for all src dependencies
# - colcon build
#
FROM ci AS robot
# robot_unbuilt **does not** colcon build, to save time
#
FROM ci AS robot_unbuilt

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

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

RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
RUN echo "if [ -f ${USER_WORKSPACE}/install/setup.bash ]; then source ${USER_WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc

FROM robot AS desktop
# Finally, build
FROM robot_unbuilt AS robot

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

FROM robot_unbuilt AS desktop_unbuilt

ENV DEBIAN_FRONTEND=noninteractive
ENV GZ_VERSION=harmonic
Expand Down Expand Up @@ -223,12 +227,6 @@ RUN sudo apt-get -q update \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# For users that build this on a laptop or system with limited RAM,
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
# This will limit the amount of RAM that colcon is allowed to use
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build

# Setup the simulation environment variables
RUN <<EOT cat >> /home/$USERNAME/.bashrc

Expand All @@ -245,6 +243,40 @@ export GZ_SIM_SYSTEM_PLUGIN_PATH=\$HOME/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_P
export GZ_SIM_RESOURCE_PATH=\$HOME/ardupilot_gazebo/models:\$HOME/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH
EOT


FROM desktop_unbuilt AS desktop

# For users that build this on a laptop or system with limited RAM,
# Modify the 'colcon build' line to be 'MAKEFLAGS="-j1 -l1" colcon build'
# This will limit the amount of RAM that colcon is allowed to use
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build

# This repetition doesn't exactly sit right ... but I can't quite figure
# out how to make this work without repeating either these instructions or
# the colcon build
FROM desktop_unbuilt AS desktop-nvidia_unbuilt

# Install NVIDIA software
RUN sudo apt-get update \
&& sudo apt-get -q -y upgrade \
&& sudo apt-get install -y -qq --no-install-recommends \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# 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


FROM desktop AS desktop-nvidia

# Install NVIDIA software
Expand Down
41 changes: 30 additions & 11 deletions .docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,56 @@ target "ci" {
platforms = ["linux/amd64", "linux/arm64"]
}

target "robot_unbuilt" {
inherits = [ "ci" ]
target = "robot_unbuilt"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-unbuilt"
]

}

target "robot" {
inherits = [ "ci", "docker-metadata-action-robot" ]
inherits = [ "robot_unbuilt", "docker-metadata-action-robot" ]
target = "robot"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot"
]
cache_to = [
"type=local,dest=.docker-cache"
}

target "desktop_unbuilt" {
inherits = [ "ci" ]
target = "desktop"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-unbuilt"
]
# amd64 only builds for desktop and desktop-nvidia
platforms = ["linux/amd64"]
}

target "desktop" {
inherits = [ "ci", "docker-metadata-action-desktop" ]
inherits = [ "desktop_unbuilt", "docker-metadata-action-desktop" ]
target = "desktop"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop"
]
cache_to = [
"type=local,dest=.docker-cache"
}

target "desktop-nvidia_unbuilt" {
inherits = [ "desktop", "docker-metadata-action-desktop-nvidia" ]
target = "desktop-nvidia_unbuilt"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia-unbuilt"
]
# amd64 only builds for desktop and desktop-nvidia
platforms = ["linux/amd64"]

}


target "desktop-nvidia" {
inherits = [ "desktop", "docker-metadata-action-desktop-nvidia" ]
target = "desktop-nvidia"
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia"
]
cache_to = [
"type=local,dest=.docker-cache"
]

}
Loading