From a560583885dc9d23b2bc59e139e7054f7325aeee Mon Sep 17 00:00:00 2001 From: Marc Hanheide Date: Sun, 15 Dec 2024 20:57:11 +0000 Subject: [PATCH 1/5] refactor: remove deprecated repository configurations and update base image in devcontainer --- .devcontainer/Dockerfile | 80 ++++----------------------- .devcontainer/devcontainer.json | 5 +- .devcontainer/gazebo_ros_pkgs.repos | 6 -- .devcontainer/lcas.repos | 5 -- .devcontainer/post-create.sh | 14 ----- .github/workflows/container-build.yml | 35 +----------- .github/workflows/devcontainer-ci.yml | 7 ++- .github/workflows/ros-ci.yml.OFF | 74 ------------------------- 8 files changed, 22 insertions(+), 204 deletions(-) delete mode 100644 .devcontainer/gazebo_ros_pkgs.repos delete mode 100644 .devcontainer/lcas.repos delete mode 100755 .devcontainer/post-create.sh delete mode 100644 .github/workflows/ros-ci.yml.OFF diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d78b2fa6..3ec16493 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl +ARG BASE_IMAGE=lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1 FROM ${BASE_IMAGE} as base @@ -7,94 +7,38 @@ ARG TARGETARCH USER root -ENV DEBIAN_FRONTEND=noninteractive - - -RUN echo "building for ${TARGETARCH}" -RUN if [ "${TARGETARCH}" = "arm64" ]; then \ - add-apt-repository -s -y ppa:openrobotics/gazebo11-non-amd64; \ - fi - -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -qq -y --no-install-recommends \ - git \ - python3-pip \ - python3-rosdep \ - python3-matplotlib \ - python3-pandas && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - # get the source tree and analyse it for its package.xml only FROM base as sourcefilter -COPY ./src /tmp/src/_workspace/src -COPY ./.devcontainer/*repos /tmp/.devcontainer/ -RUN cd /tmp/src && vcs import < /tmp/.devcontainer/lcas.repos -RUN if [ "${TARGETARCH}" = "arm64" ]; then \ - cd /tmp/src; \ - vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; \ - fi -RUN cd /tmp/src && vcs pull +RUN mkdir -p /tmp/src/ +COPY ./src/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls +COPY ./src/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls +COPY ./src/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls +COPY ./src/*/*/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls # remove everything that isn't package.xml RUN find /tmp/src -type f \! -name "package.xml" -print | xargs rm -rf # install all dependencies listed in the package.xml -FROM base as depinstaller +FROM base as devcontainer # copy the reduced source tree (only package.xml) from previous stage COPY --from=sourcefilter /tmp/src /tmp/src RUN rosdep update --rosdistro=${ROS_DISTRO} && apt-get update -RUN rosdep install --from-paths /tmp/src --ignore-src -r -y && rm -rf /tmp/src && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/src - -FROM depinstaller as depbuilder -COPY .devcontainer/*repos .devcontainer/*.sh /tmp/.devcontainer/ - -# get the source tree and build it (include gazebo only for arm64 platform as it is not available for arm64) -# see https://github.com/gazebosim/gazebo-classic/issues/3236 -RUN mkdir -p /opt/ros/lcas/src && \ - cd /opt/ros/lcas/src && \ - vcs import < /tmp/.devcontainer/lcas.repos -RUN if [ "${TARGETARCH}" = "arm64" ]; then cd /opt/ros/lcas/src; vcs import < /tmp/.devcontainer/gazebo_ros_pkgs.repos; fi +RUN . /opt/ros/lcas/install/setup.sh && rosdep install --from-paths /tmp/src --ignore-src -y && rm -rf /tmp/src && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/src -RUN . /opt/ros/humble/setup.sh && \ - apt update && \ - rosdep --rosdistro=${ROS_DISTRO} update && \ - cd /opt/ros/lcas/src && \ - vcs pull && \ - rosdep install --from-paths . -i -y && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# build the workspace but only until limo_gazebosim to avoid building the hardware specific packages -RUN cd /opt/ros/lcas; colcon build --packages-up-to limo_gazebosim; \ - rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/ - -FROM depbuilder as devcontainer -# add user ros with sudo rights if it doesn't exist -RUN if ! id ros; then \ - useradd -ms /bin/bash ros && echo "ros:ros" | chpasswd && adduser ros sudo; \ - echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \ - echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc; \ - else echo "user ros already exists"; \ - fi -RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~ros/.bashrc FROM devcontainer as compiled -COPY ./src /opt/ros/lcas/src/teaching-code/src +COPY ./src /opt/ros/lcas/src/workspace/src RUN . /opt/ros/lcas/install/setup.sh && \ apt update && \ rosdep --rosdistro=${ROS_DISTRO} update && \ - rosdep install --from-paths /opt/ros/lcas/src/teaching-code/src --ignore-src -y && \ + rosdep install --from-paths /opt/ros/lcas/src/workspace/src --ignore-src -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN cd /opt/ros/lcas && colcon build --packages-up-to uol_tidybot_control && \ +RUN cd /opt/ros/lcas && colcon build && \ rm -rf /opt/ros/lcas/src/ /opt/ros/lcas/build/ /opt/ros/lcas/log/ -RUN echo "source /opt/ros/lcas/install/setup.bash" >> ~/.bashrc -RUN find /opt/ros/lcas/ - USER ros +WORKDIR /home/ros ENV SHELL=/bin/bash diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 25edf006..6ad3a688 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,12 +9,11 @@ "dockerfile": "./Dockerfile", "args": { // set the base image, add `-arm64` as a suffix if you have an ARM (e.g. Apple Mx) CPU: - "BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl" + "BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1" }, // change this to linux/arm64 if you have an ARM (e.g. Apple Mx) CPU: "platform": "linux/amd64", - "context": "..", - "target": "devcontainer" + "context": ".." }, // forward the virtual desktop port diff --git a/.devcontainer/gazebo_ros_pkgs.repos b/.devcontainer/gazebo_ros_pkgs.repos deleted file mode 100644 index cc07da1c..00000000 --- a/.devcontainer/gazebo_ros_pkgs.repos +++ /dev/null @@ -1,6 +0,0 @@ -repositories: - gazebo_ros_pkgs: - type: git - url: https://github.com/ros-simulation/gazebo_ros_pkgs.git - version: 3.7.0 - diff --git a/.devcontainer/lcas.repos b/.devcontainer/lcas.repos deleted file mode 100644 index 827ad991..00000000 --- a/.devcontainer/lcas.repos +++ /dev/null @@ -1,5 +0,0 @@ -repositories: - limo_ros2: - type: git - url: https://github.com/LCAS/limo_ros2.git - version: v0.0.1 diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh deleted file mode 100755 index 5f849741..00000000 --- a/.devcontainer/post-create.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# source additional packages -source /opt/ros/lcas/install/setup.bash - -# ensure students always have the latest index of everything -sudo apt update -rosdep --rosdistro=${ROS_DISTRO} update - -# ensure the additional packages are always sources: -if ! grep -q "source /opt/ros/lcas/install/setup.bash" ~/.bashrc; then - echo "source /opt/ros/lcas/install/setup.bash" >> ~/.bashrc -fi - diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 75995d2c..3901c6fe 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -1,31 +1,3 @@ -# ## Build OpenGL-supported Docker Images - -# This GitHub Actions workflow is triggered when there is a push to the `2425-devel` branch or when a tag is created. It also runs when there is a pull request to the `2425-devel` branch. - -# ### Jobs - -# #### build - -# This job runs on the `lcas` runner and defines a matrix strategy to build Docker images for different configurations. - -# ##### Matrix Configuration - -# The matrix configuration includes the following variables: - -# - `base_image`: The base image for the Docker image. -# - `ros_distro`: The ROS (Robot Operating System) distribution. -# - `robot_platform`: The platform for the robot. -# - `push_tag`: The tag to be used when pushing the Docker image. - -# ##### Steps - -# The steps in the `build` job are as follows: - -# 1. Set up Node.js using the `actions/setup-node` action. -# 2. Check out the repository using the `actions/checkout` action. -# 3. Set the `BRANCH` environment variable to the branch name using a shell command. -# 4. Log in to the Docker registry (`lcas.lincoln.ac.uk`) using the `docker/login-action` action. This step is skipped for pull request events. -# 5. Build and push the Docker image using the `docker/build-push-action` action. The Dockerfile is located in the `.devcontainer/docker/ros2` directory. The image is built for the `linux/amd64` platform. The push is only performed for non-pull request events. The tags for the image are determined by the matrix configuration variables. name: Build Docker image @@ -46,8 +18,7 @@ jobs: fail-fast: false matrix: include: - - base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-1 - ros_distro: humble + - base_image: lcas.lincoln.ac.uk/lcas/limo_platform_amd64:1 push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching steps: @@ -59,6 +30,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 + submodules: 'recursive' - name: What run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV @@ -102,7 +74,6 @@ jobs: build-args: | BASE_IMAGE=${{ matrix.base_image }} BRANCH=${{ env.BRANCH }} - ROS_DISTRO=${{ matrix.ros_distro }} build-arm-docker-image: @@ -127,6 +98,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 + submodules: 'recursive' - name: What run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV @@ -171,5 +143,4 @@ jobs: build-args: | BASE_IMAGE=${{ matrix.base_image }} BRANCH=${{ env.BRANCH }} - ROS_DISTRO=${{ matrix.ros_distro }} diff --git a/.github/workflows/devcontainer-ci.yml b/.github/workflows/devcontainer-ci.yml index e0fca6fe..55eb4aa6 100644 --- a/.github/workflows/devcontainer-ci.yml +++ b/.github/workflows/devcontainer-ci.yml @@ -18,13 +18,16 @@ jobs: node-version: "^16.13.0 || >=18.0.0" - name: Checkout (GitHub) uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: 'recursive' - name: What run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Build container if: ${{ github.event_name != 'pull_request' }} uses: devcontainers/ci@v0.3 with: - imageName: devcontainer/ros2-teaching + #imageName: devcontainer/ros2-teaching push: never - imageTag: ${{ env.BRANCH }} + #imageTag: ${{ env.BRANCH }} #runCmd: "bash .devcontainer/run-ci.sh" diff --git a/.github/workflows/ros-ci.yml.OFF b/.github/workflows/ros-ci.yml.OFF deleted file mode 100644 index 0794103e..00000000 --- a/.github/workflows/ros-ci.yml.OFF +++ /dev/null @@ -1,74 +0,0 @@ -name: ros CI - -on: - push: - # you may want to configure the branches that this should be run on here. - branches: [ "2324-devel" ] - pull_request: - branches: [ "2324-devel" ] - -jobs: - test_docker: # On Linux, iterates on all ROS 1 and ROS 2 distributions. - runs-on: ubuntu-latest - strategy: - matrix: - ros_distribution: - # - noetic - - humble - # - iron - - # Define the Docker image(s) associated with each ROS distribution. - # The include syntax allows additional variables to be defined, like - # docker_image in this case. See documentation: - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-configurations-in-a-matrix-build - # - # Platforms are defined in REP 3 and REP 2000: - # https://ros.org/reps/rep-0003.html - # https://ros.org/reps/rep-2000.html - include: - # Noetic Ninjemys (May 2020 - May 2025) - # - docker_image: ubuntu:focal - # ros_distribution: noetic - # ros_version: 1 - - # Humble Hawksbill (May 2022 - May 2027) - - docker_image: lcas.lincoln.ac.uk/lcas/devcontainer/ros2-teaching:2324-devel - ros_distribution: humble - ros_version: 2 - - # Iron Irwini (May 2023 - November 2024) - # - docker_image: ubuntu:jammy - # ros_distribution: iron - # ros_version: 2 - - # # Rolling Ridley (No End-Of-Life) - # - docker_image: ubuntu:jammy - # ros_distribution: rolling - # ros_version: 2 - - container: - image: ${{ matrix.docker_image }} - steps: - - uses: actions/checkout@v3 - - name: Docker Login LCAS - uses: docker/login-action@v3 - with: - registry: lcas.lincoln.ac.uk - username: lcas - password: lincoln - - name: setup ROS environment - uses: LCAS/setup-ros@master - with: - required-ros-distributions: ${{ matrix.ros_distribution }} - - name: build and test ROS 1 ${{ matrix.ros_distribution }} - if: ${{ matrix.ros_version == 1 }} - uses: ros-tooling/action-ros-ci@v0.3 - with: - import-token: ${{ github.token }} - target-ros1-distro: ${{ matrix.ros_distribution }} - - name: build and test ROS 2 ${{ matrix.ros_distribution }} - if: ${{ matrix.ros_version == 2 }} - uses: ros-tooling/action-ros-ci@v0.3 - with: - import-token: ${{ github.token }} - target-ros2-distro: ${{ matrix.ros_distribution }} From 0066eb5e9f6e08174abeecb7bacad0b21cb33738 Mon Sep 17 00:00:00 2001 From: Marc Hanheide Date: Sun, 15 Dec 2024 20:59:46 +0000 Subject: [PATCH 2/5] allow push of staging --- .github/workflows/container-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 3901c6fe..34541e86 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -36,7 +36,6 @@ jobs: run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Docker Login LCAS - if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v3 with: registry: lcas.lincoln.ac.uk @@ -104,7 +103,6 @@ jobs: run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Docker Login LCAS - if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v3 with: registry: lcas.lincoln.ac.uk From dae06b86015ab20b0f59acf578a0a72c10ac6d82 Mon Sep 17 00:00:00 2001 From: Marc Hanheide Date: Sun, 15 Dec 2024 21:01:43 +0000 Subject: [PATCH 3/5] fix: update base image in container build workflow --- .github/workflows/container-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 34541e86..579b23f5 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -84,7 +84,7 @@ jobs: fail-fast: false matrix: include: - - base_image: lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda12.2-opengl-arm64-1 + - base_image: lcas.lincoln.ac.uk/lcas/limo_platform_arm64:1 ros_distro: humble push_image: lcas.lincoln.ac.uk/devcontainer/ros2-teaching-arm64 From b1711f1adbb4a845bcfb7a533c0ab1e5786fc0af Mon Sep 17 00:00:00 2001 From: Marc Hanheide Date: Sun, 15 Dec 2024 21:02:34 +0000 Subject: [PATCH 4/5] fix: remove conditional check for pull request in container build workflow --- .github/workflows/devcontainer-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/devcontainer-ci.yml b/.github/workflows/devcontainer-ci.yml index 55eb4aa6..d9051a4b 100644 --- a/.github/workflows/devcontainer-ci.yml +++ b/.github/workflows/devcontainer-ci.yml @@ -24,7 +24,6 @@ jobs: - name: What run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Build container - if: ${{ github.event_name != 'pull_request' }} uses: devcontainers/ci@v0.3 with: #imageName: devcontainer/ros2-teaching From fcf49cc9b6d1722974082413e1d3810a0e089354 Mon Sep 17 00:00:00 2001 From: Marc Hanheide Date: Sun, 15 Dec 2024 21:04:31 +0000 Subject: [PATCH 5/5] fix: update image name and tag in devcontainer CI workflow --- .github/workflows/devcontainer-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devcontainer-ci.yml b/.github/workflows/devcontainer-ci.yml index d9051a4b..f8052c8c 100644 --- a/.github/workflows/devcontainer-ci.yml +++ b/.github/workflows/devcontainer-ci.yml @@ -26,7 +26,7 @@ jobs: - name: Build container uses: devcontainers/ci@v0.3 with: - #imageName: devcontainer/ros2-teaching + imageName: lcas.lincoln.ac.uk/devcontainer/ros2-teaching push: never - #imageTag: ${{ env.BRANCH }} + imageTag: ci #runCmd: "bash .devcontainer/run-ci.sh"