Skip to content

Dev/use buildx bake presquash #2

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

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
907e01d
Update to use Harmonic
amarburg Aug 2, 2024
6b28953
Update main Dockerfile for "noble" base images:
amarburg Aug 5, 2024
c27e6a8
Add "third-party" rosdep from OSRF for gazebo deps.
amarburg Aug 5, 2024
6376d80
Merge remote-tracking branch 'origin/dev/gazebo_harmonic_by_default' …
amarburg Aug 5, 2024
58f74ff
Install cppzmq-dev for Gazebo
amarburg Aug 5, 2024
ac40973
Merge branch 'main' of https://github.com/Robotic-Decision-Making-Lab…
amarburg Aug 5, 2024
1590d33
Initial experiment with buildx bake
amarburg Aug 6, 2024
30e24a7
Allow "docker" action to run at any time
amarburg Aug 6, 2024
1f584a1
Try different value of "set"
amarburg Aug 6, 2024
f31984b
Try different value of "set"
amarburg Aug 6, 2024
7cd34ee
Spell action name correctly
amarburg Aug 6, 2024
d17f246
Updated keys for buildx-bake
amarburg Aug 6, 2024
023590b
Try separate caches for each stage
amarburg Aug 6, 2024
6b79efe
Change bake workdir
amarburg Aug 6, 2024
1924267
Correctly evaluate ROS_DISTRO
amarburg Aug 6, 2024
7719651
Try separate CI for PR and non-PR
amarburg Aug 6, 2024
a9dc4b7
Cleaning up caching strategy
amarburg Aug 6, 2024
b6bfb6c
Correct spelling for "matrix"
amarburg Aug 6, 2024
50b4597
Fix cache-from statement
amarburg Aug 6, 2024
df262da
Try using an anchor
amarburg Aug 6, 2024
343f087
No anchors, I guess
amarburg Aug 6, 2024
3b92d1a
Set tags and labels
amarburg Aug 6, 2024
3151887
Correct target name
amarburg Aug 6, 2024
849d0e6
Correct use of gha
amarburg Aug 6, 2024
1abeb96
Try to block concurrency
amarburg Aug 6, 2024
7959e74
Try different concurrency strategy
amarburg Aug 6, 2024
741f6f5
Transition to .hcl bake configuration
amarburg Aug 6, 2024
5340225
Merge branch 'main' into dev/use_buildx_bake_presquash
amarburg Aug 6, 2024
aa4dba0
Just one build job
amarburg Aug 6, 2024
dfcf7cf
Use repository for CI
amarburg Aug 6, 2024
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
71 changes: 46 additions & 25 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN apt-get -q update \
clang-tools \
python3-pip \
python3-dev \
python3-venv \
lsb-release \
wget \
gnupg \
Expand Down Expand Up @@ -47,14 +48,14 @@ RUN apt-get -q update \
#
FROM ci AS robot

# Configure a new non-root user
ARG USERNAME=blue
#
# Ubuntu 24.04 "Noble", which is used as the base image for
# jazzy and rolling images, now includes a user "ubuntu" at UID 1000
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& usermod -a -G dialout $USERNAME \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
Expand All @@ -65,6 +66,16 @@ ENV DEBIAN_FRONTEND=noninteractive
USER $USERNAME
ENV USER=$USERNAME

# Python in Ubuntu is now marked as a "Externally managed environment",
# Per best practice, create a venv for local python packages
#
# These two ENVs effectively "activate" the venv for subsequent calls to
# python/pip in the Dockerfile
WORKDIR /home/$USERNAME
ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install MAVROS dependencies
WORKDIR /home/$USERNAME
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
Expand Down Expand Up @@ -112,43 +123,53 @@ RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build

RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc

FROM robot AS desktop

ENV DEBIAN_FRONTEND=noninteractive
ENV GZ_VERSION=garden

# Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu
RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& 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 \
&& sudo apt-get -q update \
&& sudo apt-get -y --quiet --no-install-recommends install \
gz-garden \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
ENV GZ_VERSION=harmonic

# Install Gazebo Harmonic: https://gazebosim.org/docs/harmonic/install_ubuntu
USER root
# Install custom rosdep list
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
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& 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 \
&& apt-get -q update \
&& apt-get -y --quiet --no-install-recommends install \
gz-${GZ_VERSION} \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install ArduPilot and ardupilot_gazebo dependencies
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& sudo apt-get -q install --no-install-recommends -y \
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& apt-get -q install --no-install-recommends -y \
python3-pexpect \
python3-wxgtk4.0 \
python3-future \
rapidjson-dev \
xterm \
libgz-sim7-dev \
rapidjson-dev \
libopencv-dev \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
cppzmq-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
USER $USERNAME

# Clone ArduSub
# ArduSub is installed for simulation purposes ONLY
# When deployed onto hardware, the native installation of ArduSub
# (on the FCU) will be used.
WORKDIR /home/$USERNAME
RUN git clone https://github.com/ArduPilot/ardupilot.git --recurse-submodules
# Really should do version pinning but Sub-4.5 is waaaay behind master
# (e.g. it doesn't know about "noble" yet)
ARG ARDUPILOT_RELEASE=master
RUN git clone -b ${ARDUPILOT_RELEASE} https://github.com/ArduPilot/ardupilot.git --recurse-submodules

# Install ArduSub dependencies
WORKDIR /home/$USERNAME/ardupilot
Expand Down
2 changes: 1 addition & 1 deletion .docker/compose/nouveau-desktop.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
blue:
image: ghcr.io/robotic-decision-making-lab/blue:rolling-desktop
image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop
environment:
- DISPLAY=${DISPLAY}
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
Expand Down
2 changes: 1 addition & 1 deletion .docker/compose/nvidia-desktop.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
blue:
image: ghcr.io/robotic-decision-making-lab/blue:rolling-desktop-nvidia
image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia
environment:
- DISPLAY=${DISPLAY}
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
Expand Down
6 changes: 1 addition & 5 deletions .docker/compose/robot.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
services:
blue:
image: ghcr.io/robotic-decision-making-lab/blue:rolling-robot
build:
dockerfile: .docker/Dockerfile
target: robot
context: ../../
image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot
network_mode: host
privileged: true
cap_add:
Expand Down
58 changes: 58 additions & 0 deletions .docker/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
#
#


variable "BLUE_ROS_DISTRO" { default = "rolling" }

variable "BLUE_GITHUB_REPO" { default = "robotic-decision-making-lab/blue" }

group "default" {
targets = ["ci", "robot", "desktop", "desktop-nvidia"]
}

target "ci" {
dockerfile = ".docker/Dockerfile"
target = "ci"
context = ".."
args = {
ROS_DISTRO = "${BLUE_ROS_DISTRO}"
}
tags = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci"
]
cache_from =[
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci-cache",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-cache",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-cache",
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia-cache"
]
cache_to = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci-cache"
]
platforms = ["linux/amd64", "linux/arm64"]
}

target "robot" {
inherits = [ "ci" ]
target = "robot"
cache_to = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-cache"
]
}

target "desktop" {
inherits = [ "ci" ]
target = "desktop"
cache_to = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-cache"
]
}

target "desktop-nvidia" {
inherits = [ "ci" ]
target = "desktop-nvidia"
cache_to = [
"ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia-cache"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Run ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/blue:${{ matrix.env.IMAGE }}
DOCKER_IMAGE: ghcr.io/${{ github.repository }}:${{ matrix.env.IMAGE }}
CXXFLAGS: >-
-Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
CC: ${{ env.CLANG_TIDY && 'clang' }}
Expand Down
Loading