From 907e01d432ddcd5939ce005051a8c8d08095ce82 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Fri, 2 Aug 2024 14:54:27 -0700 Subject: [PATCH 01/27] Update to use Harmonic --- .docker/Dockerfile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c5982eab..a14e1a2d 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -102,14 +102,14 @@ RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashr FROM robot AS desktop ENV DEBIAN_FRONTEND=noninteractive -ENV GZ_VERSION=garden +ENV GZ_VERSION=harmonic -# Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu +# Install Gazebo Harmonic: https://gazebosim.org/docs/harmonic/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 \ + gz-${GZ_VERSION} \ && sudo apt-get autoremove -y \ && sudo apt-get clean -y \ && sudo rm -rf /var/lib/apt/lists/* @@ -118,10 +118,14 @@ RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrin RUN sudo apt-get -q update \ && sudo apt-get -q -y upgrade \ && sudo apt-get -q install --no-install-recommends -y \ + python3-pexpect \ python3-wxgtk4.0 \ + python3-future \ rapidjson-dev \ xterm \ - libgz-sim7-dev \ + libgz-sim?-dev \ + gz-transport?? \ + libgz-transport??-dev \ rapidjson-dev \ libopencv-dev \ && sudo apt-get autoremove -y \ @@ -133,7 +137,10 @@ RUN sudo apt-get -q update \ # 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 @@ -159,11 +166,13 @@ RUN [ "/bin/bash" , "-c" , " \ # Install ros_gz and other project dependencies WORKDIR $USER_WORKSPACE +# Some gz_* rosdep keys must be skipped because they are not in the rosdep yaml humble/iron +# (despite the fact the packages are available). Ensure they are installed manually. RUN sudo apt-get -q update \ && sudo apt-get -q -y upgrade \ && vcs import src < src/blue/blue.repos \ && rosdep update \ - && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \ + && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport13 gz-sim8 gz-math7 gz-msgs10" \ && sudo apt-get autoremove -y \ && sudo apt-get clean -y \ && sudo rm -rf /var/lib/apt/lists/* From 6b28953a0567c56fc6a05fd11313b358c600ca6e Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 09:42:16 -0700 Subject: [PATCH 02/27] Update main Dockerfile for "noble" base images: - Use the provided user "ubuntu" at UID 1000 - Use a venv for user-installed python packages --- .docker/Dockerfile | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a14e1a2d..d0b982fc 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -18,6 +18,7 @@ RUN apt-get -q update \ clang-tools \ python3-pip \ python3-dev \ + python3-venv \ lsb-release \ wget \ gnupg \ @@ -38,14 +39,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 @@ -56,6 +57,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 \ @@ -97,7 +108,8 @@ RUN sudo apt-get -q update \ && sudo rm -rf /var/lib/apt/lists/* 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 From c27e6a8d248b5a9dc2e1a508bb1f785a164f7fd2 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 13:34:02 -0700 Subject: [PATCH 03/27] Add "third-party" rosdep from OSRF for gazebo deps. --- .docker/Dockerfile | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a14e1a2d..e7709983 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -105,32 +105,33 @@ ENV DEBIAN_FRONTEND=noninteractive ENV GZ_VERSION=harmonic # Install Gazebo Harmonic: https://gazebosim.org/docs/harmonic/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 \ +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} \ - && sudo apt-get autoremove -y \ - && sudo apt-get clean -y \ - && sudo rm -rf /var/lib/apt/lists/* + && 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-sim?-dev \ - gz-transport?? \ - libgz-transport??-dev \ rapidjson-dev \ libopencv-dev \ - && sudo apt-get autoremove -y \ - && sudo apt-get clean -y \ - && sudo rm -rf /var/lib/apt/lists/* + && 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 @@ -166,13 +167,11 @@ RUN [ "/bin/bash" , "-c" , " \ # Install ros_gz and other project dependencies WORKDIR $USER_WORKSPACE -# Some gz_* rosdep keys must be skipped because they are not in the rosdep yaml humble/iron -# (despite the fact the packages are available). Ensure they are installed manually. RUN sudo apt-get -q update \ && sudo apt-get -q -y upgrade \ && vcs import src < src/blue/blue.repos \ && rosdep update \ - && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport13 gz-sim8 gz-math7 gz-msgs10" \ + && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \ && sudo apt-get autoremove -y \ && sudo apt-get clean -y \ && sudo rm -rf /var/lib/apt/lists/* From 58f74ffe281bab59a2784da35faa733f4d4b7c41 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 14:39:08 -0700 Subject: [PATCH 04/27] Install cppzmq-dev for Gazebo --- .docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 2c89866f..e76bd08e 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -140,6 +140,7 @@ RUN apt-get -q update \ xterm \ rapidjson-dev \ libopencv-dev \ + cppzmq-dev \ && apt-get autoremove -y \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* From 1590d336bece09e0356bcbae4532781d5a35e8aa Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 17:39:39 -0700 Subject: [PATCH 05/27] Initial experiment with buildx bake --- .docker/.env | 5 + .docker/docker-compose.yaml | 35 +++++ .github/workflows/ci.yaml | 2 +- .github/workflows/docker.yaml | 288 ++++++++++++++++++---------------- 4 files changed, 195 insertions(+), 135 deletions(-) create mode 100644 .docker/.env create mode 100644 .docker/docker-compose.yaml diff --git a/.docker/.env b/.docker/.env new file mode 100644 index 00000000..ab67bb5d --- /dev/null +++ b/.docker/.env @@ -0,0 +1,5 @@ +# +# +# +BLUE_ROS_DISTRO=jazzy +BLUE_GITHUB_REPO=apl-ocean-engineering/blue diff --git a/.docker/docker-compose.yaml b/.docker/docker-compose.yaml new file mode 100644 index 00000000..7bc0c44e --- /dev/null +++ b/.docker/docker-compose.yaml @@ -0,0 +1,35 @@ +# The following variables are loaded from the .env file +# BLUE_BLUE_GITHUB_REPO +# BLUE_ROS_DISTRO +# +# These targets are exclusively for building respective images. See compose/ for running images. + +services: + robot: + image: ghcr.io/${BLUE_GITHUB_REPO:?Github repo not set}:${BLUE_ROS_DISTRO:?BLUE_ROS_DISTRO not set}-robot + build: &default_build + dockerfile: .docker/Dockerfile + target: robot + context: ../ + args: + - ROS_DISTRO=${BLUE_ROS_DISTRO} + cache_from: + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-cache + cache_to: + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-cache + x-bake: + platforms: + - linux/amd64 + # - linux/arm64 + + desktop: + build: + <<: *default_build + target: desktop + image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop + + desktop-nvidia: + build: + <<: *default_build + target: desktop-nvidia + image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e8ff75ad..e52b9b3b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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/${{ env.GITHUB_REPOSITORY }}:${{ matrix.env.IMAGE }} CXXFLAGS: >- -Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls CC: ${{ env.CLANG_TIDY && 'clang' }} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 82fe5a2b..36150ee1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -28,140 +28,22 @@ jobs: packages: write contents: read steps: - - name: Checkout repository + - + name: Checkout repository uses: actions/checkout@v4 - - name: Log into registry - if: env.PUSH == 'true' - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract Docker metadata - if: env.PUSH == 'true' - id: meta - uses: docker/metadata-action@v5.5.1 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6.5.0 - with: - context: . - file: .docker/Dockerfile - build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} - target: ${{ github.job }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - push: ${{ env.PUSH }} - - robot: - strategy: - fail-fast: false - matrix: - ROS_DISTRO: [rolling] - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@v4 + - + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.2.0 - - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log into registry - if: env.PUSH == 'true' - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract Docker metadata - if: env.PUSH == 'true' - id: meta - uses: docker/metadata-action@v5.5.1 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6.5.0 - with: - context: . - file: .docker/Dockerfile - build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} - target: ${{ github.job }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - push: ${{ env.PUSH }} - platforms: linux/amd64,linux/arm64 - - desktop: - strategy: - fail-fast: false - matrix: - ROS_DISTRO: [rolling] - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log into registry - if: env.PUSH == 'true' - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract Docker metadata - if: env.PUSH == 'true' - id: meta - uses: docker/metadata-action@v5.5.1 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6.5.0 - with: - context: . - file: .docker/Dockerfile - build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} - target: ${{ github.job }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - push: ${{ env.PUSH }} - - desktop-nvidia: - strategy: - fail-fast: false - matrix: - ROS_DISTRO: [rolling] - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log into registry + - + name: Log into registry if: env.PUSH == 'true' uses: docker/login-action@v3.3.0 with: @@ -169,7 +51,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract Docker metadata + - + name: Extract Docker metadata if: env.PUSH == 'true' id: meta uses: docker/metadata-action@v5.5.1 @@ -178,13 +61,150 @@ jobs: tags: | type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} - - name: Build and push Docker image - uses: docker/build-push-action@v6.5.0 + - + name: Build and push + uses: docker/bake-actionn@v5 with: context: . - file: .docker/Dockerfile - build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + files: .docker/docker-compose.yaml target: ${{ github.job }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} push: ${{ env.PUSH }} + set: + - "*.platform=linux/amd64" + env: + BLUE_ROS_DISTRO: matrix.ROS_DISTRO + BLUE_BLUE_GITHUB_REPO: ${{ github.repository }} + + + + # robot: + # strategy: + # fail-fast: false + # matrix: + # ROS_DISTRO: [rolling] + # runs-on: ubuntu-latest + # permissions: + # packages: write + # contents: read + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3.2.0 + + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + + # - name: Log into registry + # if: env.PUSH == 'true' + # uses: docker/login-action@v3.3.0 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Extract Docker metadata + # if: env.PUSH == 'true' + # id: meta + # uses: docker/metadata-action@v5.5.1 + # with: + # images: ghcr.io/${{ github.repository }} + # tags: | + # type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + # - name: Build and push Docker image + # uses: docker/build-push-action@v6.5.0 + # with: + # context: . + # file: .docker/Dockerfile + # build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + # target: ${{ github.job }} + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # push: ${{ env.PUSH }} + # platforms: linux/amd64,linux/arm64 + + # desktop: + # strategy: + # fail-fast: false + # matrix: + # ROS_DISTRO: [rolling] + # runs-on: ubuntu-latest + # permissions: + # packages: write + # contents: read + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Log into registry + # if: env.PUSH == 'true' + # uses: docker/login-action@v3.3.0 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Extract Docker metadata + # if: env.PUSH == 'true' + # id: meta + # uses: docker/metadata-action@v5.5.1 + # with: + # images: ghcr.io/${{ github.repository }} + # tags: | + # type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + # - name: Build and push Docker image + # uses: docker/build-push-action@v6.5.0 + # with: + # context: . + # file: .docker/Dockerfile + # build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + # target: ${{ github.job }} + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # push: ${{ env.PUSH }} + + # desktop-nvidia: + # strategy: + # fail-fast: false + # matrix: + # ROS_DISTRO: [rolling] + # runs-on: ubuntu-latest + # permissions: + # packages: write + # contents: read + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + + # - name: Log into registry + # if: env.PUSH == 'true' + # uses: docker/login-action@v3.3.0 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Extract Docker metadata + # if: env.PUSH == 'true' + # id: meta + # uses: docker/metadata-action@v5.5.1 + # with: + # images: ghcr.io/${{ github.repository }} + # tags: | + # type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + + # - name: Build and push Docker image + # uses: docker/build-push-action@v6.5.0 + # with: + # context: . + # file: .docker/Dockerfile + # build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }} + # target: ${{ github.job }} + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # push: ${{ env.PUSH }} From 30e24a70ad081c029b8f1e8c554bd197723e2d54 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 17:46:39 -0700 Subject: [PATCH 06/27] Allow "docker" action to run at any time --- .github/workflows/docker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 36150ee1..c9eeb64b 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,8 +1,8 @@ name: Docker on: - schedule: - - cron: "0 17 * * 6" + # schedule: + # - cron: "0 17 * * 6" push: branches: - main From 1f584a1ec903195822970652229b4ee6f483f53d Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 17:57:31 -0700 Subject: [PATCH 07/27] Try different value of "set" --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index c9eeb64b..070a111e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -72,7 +72,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} push: ${{ env.PUSH }} set: - - "*.platform=linux/amd64" + - ${{ github.job }}.platform"="linux/amd64" env: BLUE_ROS_DISTRO: matrix.ROS_DISTRO BLUE_BLUE_GITHUB_REPO: ${{ github.repository }} From f31984ba10365ff749fb415ae723f9fcd2697793 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 17:58:23 -0700 Subject: [PATCH 08/27] Try different value of "set" --- .github/workflows/docker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 070a111e..162a623d 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -71,8 +71,8 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} push: ${{ env.PUSH }} - set: - - ${{ github.job }}.platform"="linux/amd64" + set: | + *.platform=linux/amd64 env: BLUE_ROS_DISTRO: matrix.ROS_DISTRO BLUE_BLUE_GITHUB_REPO: ${{ github.repository }} From 7cd34ee7be854119b11f4b4a889ddee1d38d7304 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 18:00:03 -0700 Subject: [PATCH 09/27] Spell action name correctly --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 162a623d..5c0b337c 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -63,7 +63,7 @@ jobs: - name: Build and push - uses: docker/bake-actionn@v5 + uses: docker/bake-action@v5.5.0 with: context: . files: .docker/docker-compose.yaml From d17f246727d14323483658d0f068d2a411172267 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 18:03:21 -0700 Subject: [PATCH 10/27] Updated keys for buildx-bake --- .github/workflows/docker.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 5c0b337c..d9e6f4cc 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -65,17 +65,16 @@ jobs: name: Build and push uses: docker/bake-action@v5.5.0 with: - context: . + source: . files: .docker/docker-compose.yaml - target: ${{ github.job }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + targets: | + ${{ github.job }} push: ${{ env.PUSH }} set: | *.platform=linux/amd64 env: BLUE_ROS_DISTRO: matrix.ROS_DISTRO - BLUE_BLUE_GITHUB_REPO: ${{ github.repository }} + BLUE_GITHUB_REPO: ${{ github.repository }} From 023590b5d5705c782814cd4c5167a5a8a40caefb Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:18:59 -0700 Subject: [PATCH 11/27] Try separate caches for each stage --- .docker/docker-compose.yaml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.docker/docker-compose.yaml b/.docker/docker-compose.yaml index 7bc0c44e..ad7151fe 100644 --- a/.docker/docker-compose.yaml +++ b/.docker/docker-compose.yaml @@ -5,31 +5,46 @@ # These targets are exclusively for building respective images. See compose/ for running images. services: - robot: - image: ghcr.io/${BLUE_GITHUB_REPO:?Github repo not set}:${BLUE_ROS_DISTRO:?BLUE_ROS_DISTRO not set}-robot + ci: + image: ghcr.io/${BLUE_GITHUB_REPO:?Github repo not set}:${BLUE_ROS_DISTRO:?BLUE_ROS_DISTRO not set}-ci build: &default_build dockerfile: .docker/Dockerfile - target: robot + target: ci context: ../ args: - ROS_DISTRO=${BLUE_ROS_DISTRO} cache_from: - - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-cache + - 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}-cache + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-ci-cache x-bake: platforms: - linux/amd64 # - linux/arm64 + robot: + build: + <<: *default_build + target: robot + cache_to: + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-cache + image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot + desktop: build: <<: *default_build target: desktop + cache_to: + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-cache image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop desktop-nvidia: build: <<: *default_build target: desktop-nvidia + cache_to: + - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia-cache image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia From 6b79efe178232c950836ca941698e3164dd34782 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:21:42 -0700 Subject: [PATCH 12/27] Change bake workdir --- .github/workflows/docker.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d9e6f4cc..1cf022bc 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -66,7 +66,8 @@ jobs: uses: docker/bake-action@v5.5.0 with: source: . - files: .docker/docker-compose.yaml + workdir: .docker + files: docker-compose.yaml targets: | ${{ github.job }} push: ${{ env.PUSH }} From 1924267aa22ca1904d1ca3b1a2c7f9fe55945441 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:25:32 -0700 Subject: [PATCH 13/27] Correctly evaluate ROS_DISTRO --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 1cf022bc..176a044e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -74,7 +74,7 @@ jobs: set: | *.platform=linux/amd64 env: - BLUE_ROS_DISTRO: matrix.ROS_DISTRO + BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} BLUE_GITHUB_REPO: ${{ github.repository }} From 7719651c3f1c20bbc345d6b69f8292ca1b9279a9 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:46:44 -0700 Subject: [PATCH 14/27] Try separate CI for PR and non-PR --- .github/workflows/docker.yaml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 176a044e..42692022 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -27,6 +27,9 @@ jobs: permissions: packages: write contents: read + env: + BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} + BLUE_GITHUB_REPO: ${{ github.repository }} steps: - name: Checkout repository @@ -42,9 +45,9 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + # Always login to be able to write to cache - name: Log into registry - if: env.PUSH == 'true' uses: docker/login-action@v3.3.0 with: registry: ghcr.io @@ -61,22 +64,37 @@ jobs: tags: | type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} - - - name: Build and push + - if: github.event_name == 'push' + name: Build and push (non PR) uses: docker/bake-action@v5.5.0 with: source: . workdir: .docker - files: docker-compose.yaml targets: | ${{ github.job }} push: ${{ env.PUSH }} set: | *.platform=linux/amd64 + *.cache-from=gha + *.cache-to=gha env: BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} BLUE_GITHUB_REPO: ${{ github.repository }} + - if: github.event_name == 'pull_request' + name: Build and push (non PR) + uses: docker/bake-action@v5.5.0 + with: + source: . + workdir: .docker + targets: | + ${{ github.job }} + set: | + *.platform=linux/amd64 + *.cache-from=gha + *.cache-to= + + # robot: From a9dc4b7ae1b3ec7d6f4293d812fedb6c2f8db560 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:53:16 -0700 Subject: [PATCH 15/27] Cleaning up caching strategy --- .github/workflows/docker.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 42692022..d1c42f83 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -18,11 +18,12 @@ env: PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'Robotic-Decision-Making-Lab/blue') }} jobs: - ci: + docker_build: strategy: fail-fast: false matrix: ROS_DISTRO: [rolling] + stage: [ci, robot, desktop, nvidia-desktop] runs-on: ubuntu-latest permissions: packages: write @@ -45,8 +46,8 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # Always login to be able to write to cache - + if: env.PUSH == 'true' name: Log into registry uses: docker/login-action@v3.3.0 with: @@ -62,7 +63,7 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }} + type=raw,value=${{ matrix.ROS_DISTRO }}-${{ maxtrix.stage }} - if: github.event_name == 'push' name: Build and push (non PR) @@ -75,8 +76,8 @@ jobs: push: ${{ env.PUSH }} set: | *.platform=linux/amd64 - *.cache-from=gha - *.cache-to=gha + *.cache-from=gha,scope=${{ maxtrix.stage }} + *.cache-to=gha,scope=${{ maxtrix.stage }} env: BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} BLUE_GITHUB_REPO: ${{ github.repository }} @@ -91,7 +92,7 @@ jobs: ${{ github.job }} set: | *.platform=linux/amd64 - *.cache-from=gha + *.cache-from=gha,${{ maxtrix.stage }} *.cache-to= From b6bfb6c7ff53c0fd75032d3359371897a9bfe529 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:59:17 -0700 Subject: [PATCH 16/27] Correct spelling for "matrix" --- .github/workflows/docker.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d1c42f83..9bf887b5 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -63,21 +63,20 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ maxtrix.stage }} + type=raw,value=${{ matrix.ROS_DISTRO }}-${{ matrix.stage }} - if: github.event_name == 'push' name: Build and push (non PR) uses: docker/bake-action@v5.5.0 with: - source: . workdir: .docker targets: | ${{ github.job }} push: ${{ env.PUSH }} set: | *.platform=linux/amd64 - *.cache-from=gha,scope=${{ maxtrix.stage }} - *.cache-to=gha,scope=${{ maxtrix.stage }} + *.cache-from=gha,scope=${{ matrix.stage }} + *.cache-to=gha,mode=max,scope=${{ matrix.stage }} env: BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} BLUE_GITHUB_REPO: ${{ github.repository }} @@ -86,13 +85,12 @@ jobs: name: Build and push (non PR) uses: docker/bake-action@v5.5.0 with: - source: . workdir: .docker targets: | ${{ github.job }} set: | *.platform=linux/amd64 - *.cache-from=gha,${{ maxtrix.stage }} + *.cache-from=gha,${{ matrix.stage }} *.cache-to= From 50b459741cbe755f0d55938b92a825618ebc9adc Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 21:59:54 -0700 Subject: [PATCH 17/27] Fix cache-from statement --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9bf887b5..17f2a968 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -90,7 +90,7 @@ jobs: ${{ github.job }} set: | *.platform=linux/amd64 - *.cache-from=gha,${{ matrix.stage }} + *.cache-from=gha,scope=${{ matrix.stage }} *.cache-to= From df262dab095db59fe52823f5dd73209973c693d5 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 22:02:59 -0700 Subject: [PATCH 18/27] Try using an anchor --- .github/workflows/docker.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 17f2a968..9880c5be 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -68,7 +68,7 @@ jobs: - if: github.event_name == 'push' name: Build and push (non PR) uses: docker/bake-action@v5.5.0 - with: + with: &build_with workdir: .docker targets: | ${{ github.job }} @@ -77,17 +77,12 @@ jobs: *.platform=linux/amd64 *.cache-from=gha,scope=${{ matrix.stage }} *.cache-to=gha,mode=max,scope=${{ matrix.stage }} - env: - BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }} - BLUE_GITHUB_REPO: ${{ github.repository }} - if: github.event_name == 'pull_request' - name: Build and push (non PR) + name: Build and push (PR) uses: docker/bake-action@v5.5.0 with: - workdir: .docker - targets: | - ${{ github.job }} + <<: *build_with set: | *.platform=linux/amd64 *.cache-from=gha,scope=${{ matrix.stage }} From 343f087639607c4197a33f191879273899e2ce58 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 22:07:03 -0700 Subject: [PATCH 19/27] No anchors, I guess --- .github/workflows/docker.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9880c5be..c616180b 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -68,7 +68,7 @@ jobs: - if: github.event_name == 'push' name: Build and push (non PR) uses: docker/bake-action@v5.5.0 - with: &build_with + with: workdir: .docker targets: | ${{ github.job }} @@ -82,7 +82,9 @@ jobs: name: Build and push (PR) uses: docker/bake-action@v5.5.0 with: - <<: *build_with + workdir: .docker + targets: | + ${{ github.job }} set: | *.platform=linux/amd64 *.cache-from=gha,scope=${{ matrix.stage }} From 3b92d1a5405d710b9d083368b373b970e79a9d6d Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 22:10:49 -0700 Subject: [PATCH 20/27] Set tags and labels --- .github/workflows/docker.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index c616180b..bccc5907 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -71,12 +71,15 @@ jobs: with: workdir: .docker targets: | - ${{ github.job }} + ${{ matrix.stage }} push: ${{ env.PUSH }} set: | *.platform=linux/amd64 *.cache-from=gha,scope=${{ matrix.stage }} *.cache-to=gha,mode=max,scope=${{ matrix.stage }} + *.tags=${{ steps.meta.outputs.tags }} + *.labels=${{ steps.meta.outputs.labels }} + - if: github.event_name == 'pull_request' name: Build and push (PR) @@ -84,7 +87,7 @@ jobs: with: workdir: .docker targets: | - ${{ github.job }} + ${{ matrix.stage }} set: | *.platform=linux/amd64 *.cache-from=gha,scope=${{ matrix.stage }} From 3151887f5e38598a9d269482c54b00b0e45751ef Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 22:13:20 -0700 Subject: [PATCH 21/27] Correct target name --- .docker/docker-compose.yaml | 1 + .github/workflows/docker.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.docker/docker-compose.yaml b/.docker/docker-compose.yaml index ad7151fe..b7aedabd 100644 --- a/.docker/docker-compose.yaml +++ b/.docker/docker-compose.yaml @@ -3,6 +3,7 @@ # BLUE_ROS_DISTRO # # These targets are exclusively for building respective images. See compose/ for running images. +# services: ci: diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index bccc5907..3917d3c1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: ROS_DISTRO: [rolling] - stage: [ci, robot, desktop, nvidia-desktop] + stage: [ci, robot, desktop, desktop-nvidia] runs-on: ubuntu-latest permissions: packages: write From 849d0e6b3254c9005c2a5839c1c4dc5b49f5b14a Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Mon, 5 Aug 2024 22:20:41 -0700 Subject: [PATCH 22/27] Correct use of gha --- .github/workflows/docker.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 3917d3c1..fafd9fc6 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -75,8 +75,8 @@ jobs: push: ${{ env.PUSH }} set: | *.platform=linux/amd64 - *.cache-from=gha,scope=${{ matrix.stage }} - *.cache-to=gha,mode=max,scope=${{ matrix.stage }} + *.cache-from=type=gha,scope=${{ matrix.stage }} + *.cache-to=type=gha,mode=max,scope=${{ matrix.stage }} *.tags=${{ steps.meta.outputs.tags }} *.labels=${{ steps.meta.outputs.labels }} @@ -90,7 +90,7 @@ jobs: ${{ matrix.stage }} set: | *.platform=linux/amd64 - *.cache-from=gha,scope=${{ matrix.stage }} + *.cache-from=type=gha,scope=${{ matrix.stage }} *.cache-to= From 1abeb96899d22b0871cf918616b3020b1ef5d0c1 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Tue, 6 Aug 2024 07:53:50 -0700 Subject: [PATCH 23/27] Try to block concurrency --- .github/workflows/docker.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index fafd9fc6..94cfdb7e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -24,6 +24,9 @@ jobs: matrix: ROS_DISTRO: [rolling] stage: [ci, robot, desktop, desktop-nvidia] + concurrency: + group: docker_build + cancel-in-progress: false runs-on: ubuntu-latest permissions: packages: write @@ -75,7 +78,10 @@ jobs: push: ${{ env.PUSH }} set: | *.platform=linux/amd64 - *.cache-from=type=gha,scope=${{ matrix.stage }} + *.cache-from=type=gha,scope=ci + *.cache-from=type=gha,scope=robot + *.cache-from=type=gha,scope=desktop + *.cache-from=type=gha,scope=desktop-nvidia *.cache-to=type=gha,mode=max,scope=${{ matrix.stage }} *.tags=${{ steps.meta.outputs.tags }} *.labels=${{ steps.meta.outputs.labels }} @@ -90,7 +96,10 @@ jobs: ${{ matrix.stage }} set: | *.platform=linux/amd64 - *.cache-from=type=gha,scope=${{ matrix.stage }} + *.cache-from=type=gha,scope=ci + *.cache-from=type=gha,scope=robot + *.cache-from=type=gha,scope=desktop + *.cache-from=type=gha,scope=desktop-nvidia *.cache-to= From 7959e74035d627d8e17e9f62847b4dc0b28f4af8 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Tue, 6 Aug 2024 07:59:34 -0700 Subject: [PATCH 24/27] Try different concurrency strategy --- .github/workflows/docker.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 94cfdb7e..21663062 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -21,12 +21,10 @@ jobs: docker_build: strategy: fail-fast: false + max-parallel: 1 matrix: ROS_DISTRO: [rolling] stage: [ci, robot, desktop, desktop-nvidia] - concurrency: - group: docker_build - cancel-in-progress: false runs-on: ubuntu-latest permissions: packages: write From 741f6f580fc01534d8d7409ec7cd1e059cd433d7 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Tue, 6 Aug 2024 11:39:54 -0700 Subject: [PATCH 25/27] Transition to .hcl bake configuration --- .docker/compose/nouveau-desktop.yaml | 2 +- .docker/compose/nvidia-desktop.yaml | 2 +- .docker/compose/robot.yaml | 6 +-- .docker/docker-bake.hcl | 58 ++++++++++++++++++++++++++++ .docker/docker-compose.yaml | 51 ------------------------ .gitignore | 2 + 6 files changed, 63 insertions(+), 58 deletions(-) create mode 100644 .docker/docker-bake.hcl delete mode 100644 .docker/docker-compose.yaml diff --git a/.docker/compose/nouveau-desktop.yaml b/.docker/compose/nouveau-desktop.yaml index f18588de..0f62bd89 100644 --- a/.docker/compose/nouveau-desktop.yaml +++ b/.docker/compose/nouveau-desktop.yaml @@ -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} diff --git a/.docker/compose/nvidia-desktop.yaml b/.docker/compose/nvidia-desktop.yaml index da240d51..b7046b56 100644 --- a/.docker/compose/nvidia-desktop.yaml +++ b/.docker/compose/nvidia-desktop.yaml @@ -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} diff --git a/.docker/compose/robot.yaml b/.docker/compose/robot.yaml index faf1be02..f3c79ff9 100644 --- a/.docker/compose/robot.yaml +++ b/.docker/compose/robot.yaml @@ -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: diff --git a/.docker/docker-bake.hcl b/.docker/docker-bake.hcl new file mode 100644 index 00000000..8aad319b --- /dev/null +++ b/.docker/docker-bake.hcl @@ -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" + ] +} diff --git a/.docker/docker-compose.yaml b/.docker/docker-compose.yaml deleted file mode 100644 index b7aedabd..00000000 --- a/.docker/docker-compose.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# The following variables are loaded from the .env file -# BLUE_BLUE_GITHUB_REPO -# BLUE_ROS_DISTRO -# -# These targets are exclusively for building respective images. See compose/ for running images. -# - -services: - ci: - image: ghcr.io/${BLUE_GITHUB_REPO:?Github repo not set}:${BLUE_ROS_DISTRO:?BLUE_ROS_DISTRO not set}-ci - build: &default_build - dockerfile: .docker/Dockerfile - target: ci - context: ../ - args: - - ROS_DISTRO=${BLUE_ROS_DISTRO} - 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 - x-bake: - platforms: - - linux/amd64 - # - linux/arm64 - - robot: - build: - <<: *default_build - target: robot - cache_to: - - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot-cache - image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-robot - - desktop: - build: - <<: *default_build - target: desktop - cache_to: - - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-cache - image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop - - desktop-nvidia: - build: - <<: *default_build - target: desktop-nvidia - cache_to: - - ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia-cache - image: ghcr.io/${BLUE_GITHUB_REPO}:${BLUE_ROS_DISTRO}-desktop-nvidia diff --git a/.gitignore b/.gitignore index eb28dd58..3d806e06 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ mav.parm mav.tlog mav.tlog.raw logs/ + +.docker/docker-bake.override.hcl From aa4dba0bd4178fbdae3d597f4da5be5492b3fad1 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Tue, 6 Aug 2024 11:48:30 -0700 Subject: [PATCH 26/27] Just one build job --- .docker/.env | 5 ----- .github/workflows/docker.yaml | 30 +++++++++++++----------------- 2 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 .docker/.env diff --git a/.docker/.env b/.docker/.env deleted file mode 100644 index ab67bb5d..00000000 --- a/.docker/.env +++ /dev/null @@ -1,5 +0,0 @@ -# -# -# -BLUE_ROS_DISTRO=jazzy -BLUE_GITHUB_REPO=apl-ocean-engineering/blue diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 278dcce2..335826e2 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -21,10 +21,8 @@ jobs: docker_build: strategy: fail-fast: false - max-parallel: 1 matrix: ROS_DISTRO: [rolling] - stage: [ci, robot, desktop, desktop-nvidia] runs-on: ubuntu-latest permissions: packages: write @@ -56,23 +54,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract Docker metadata - if: env.PUSH == 'true' - id: meta - uses: docker/metadata-action@v5.5.1 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ matrix.ROS_DISTRO }}-${{ matrix.stage }} + # - + # name: Extract Docker metadata + # if: env.PUSH == 'true' + # id: meta + # uses: docker/metadata-action@v5.5.1 + # with: + # images: ghcr.io/${{ github.repository }} + # tags: | + # type=raw,value=${{ matrix.ROS_DISTRO }}-${{ matrix.stage }} - if: github.event_name == 'push' name: Build and push (non PR) uses: docker/bake-action@v5.5.0 with: workdir: .docker - targets: | - ${{ matrix.stage }} push: ${{ env.PUSH }} set: | *.platform=linux/amd64 @@ -80,10 +76,10 @@ jobs: *.cache-from=type=gha,scope=robot *.cache-from=type=gha,scope=desktop *.cache-from=type=gha,scope=desktop-nvidia - *.cache-to=type=gha,mode=max,scope=${{ matrix.stage }} - *.tags=${{ steps.meta.outputs.tags }} - *.labels=${{ steps.meta.outputs.labels }} - + ci.cache-to=type=gha,mode=max,scope=ci + robot.cache-to=type=gha,mode=max,scope=robot + desktop.cache-to=type=gha,mode=max,scope=desktop + desktop-nvidia.cache-to=type=gha,mode=max,scope=desktop-nvidia - if: github.event_name == 'pull_request' name: Build and push (PR) From dfcf7cf183bad3565833e18008a999d21502ffc6 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Tue, 6 Aug 2024 14:52:20 -0700 Subject: [PATCH 27/27] Use repository for CI --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e52b9b3b..ba678edc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,7 +37,7 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master env: - DOCKER_IMAGE: ghcr.io/${{ env.GITHUB_REPOSITORY }}:${{ 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' }}