From c3e022c5679ab74a253c0d489e068349e0f6a724 Mon Sep 17 00:00:00 2001 From: Mischa Taylor Date: Sun, 24 Nov 2024 18:52:13 -0500 Subject: [PATCH] Add ROSDISTRO_PKGS_SYNC_DATE environment variable --- .github/workflows/ci.yml | 1 + ros/rolling/ubuntu/jammy/Containerfile | 4 +- ros/rolling/ubuntu/jammy/docker-bake.hcl | 1 + .../ubuntu/jammy/test/controls/ros_rolling.rb | 4 + ros/rolling/ubuntu/noble/Containerfile | 104 ++++++++++++++++++ ros/rolling/ubuntu/noble/docker-bake.hcl | 55 +++++++++ ros/rolling/ubuntu/noble/ros_entrypoint.sh | 6 + .../ubuntu/noble/test/controls/ros_rolling.rb | 78 +++++++++++++ 8 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 ros/rolling/ubuntu/noble/Containerfile create mode 100644 ros/rolling/ubuntu/noble/docker-bake.hcl create mode 100755 ros/rolling/ubuntu/noble/ros_entrypoint.sh create mode 100644 ros/rolling/ubuntu/noble/test/controls/ros_rolling.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aff8e7ee..e3581524 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,6 +196,7 @@ jobs: ros/jazzy/ubuntu/noble: 'ros/jazzy/ubuntu/noble/**' ros/noetic/ubuntu/focal: 'ros/noetic/ubuntu/focal/**' ros/rolling/ubuntu/jammy: 'ros/rolling/ubuntu/jammy/**' + ros/rolling/ubuntu/noble: 'ros/rolling/ubuntu/noble/**' polymath-ros/humble/ubuntu/jammy: 'polymath-ros/humble/ubuntu/jammy/**' polymath-ros/iron/ubuntu/jammy: 'polymath-ros/iron/ubuntu/jammy/**' polymath-ros/jazzy/ubuntu/noble: 'polymath-ros/jazzy/ubuntu/noble/**' diff --git a/ros/rolling/ubuntu/jammy/Containerfile b/ros/rolling/ubuntu/jammy/Containerfile index 511834cf..ff22e407 100644 --- a/ros/rolling/ubuntu/jammy/Containerfile +++ b/ros/rolling/ubuntu/jammy/Containerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -ARG BASE_IMAGE=docker.io/ubuntu:jammy-20240808 +ARG BASE_IMAGE=docker.io/ubuntu:jammy-20240911.1 # hadolint ignore=DL3006 FROM ${BASE_IMAGE} AS base @@ -20,6 +20,7 @@ EOF FROM base AS ros-core ARG ROS_PACKAGES_URI +ARG ROSDISTRO_PKGS_SYNC_DATE COPY --from=download /usr/share/keyrings/ros2-latest-archive-keyring.gpg /usr/share/keyrings/ros2-latest-archive-keyring.gpg @@ -43,6 +44,7 @@ RUN echo "deb [ signed-by=/usr/share/keyrings/ros2-latest-archive-keyring.gpg ] ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 +ENV ROSDISTRO_PKGS_SYNC_DATE=$ROSDISTRO_PKGS_SYNC_DATE ENV ROS_DISTRO=rolling # install ros2 packages diff --git a/ros/rolling/ubuntu/jammy/docker-bake.hcl b/ros/rolling/ubuntu/jammy/docker-bake.hcl index 7c7d18ce..007dc439 100644 --- a/ros/rolling/ubuntu/jammy/docker-bake.hcl +++ b/ros/rolling/ubuntu/jammy/docker-bake.hcl @@ -15,6 +15,7 @@ target "_common" { args = { ROS_PACKAGES_URI = "http://packages.ros.org/ros2/ubuntu" RAW_GITHUBUSERCONTENT_BASE_URL = "https://raw.githubusercontent.com" + ROSDISTRO_PKGS_SYNC_DATE = "${formatdate("YYYY-MM-DD", timestamp())}" } dockerfile = "Containerfile" labels = { diff --git a/ros/rolling/ubuntu/jammy/test/controls/ros_rolling.rb b/ros/rolling/ubuntu/jammy/test/controls/ros_rolling.rb index 99793ba0..b7740775 100644 --- a/ros/rolling/ubuntu/jammy/test/controls/ros_rolling.rb +++ b/ros/rolling/ubuntu/jammy/test/controls/ros_rolling.rb @@ -6,6 +6,10 @@ its('content') { should eq 'C.UTF-8' } end +describe os_env('ROSDISTRO_PKGS_SYNC_DATE') do + its('content') { should match /^\d{4}-\d{2}-\d{2}$/ } +end + describe file('/usr/share/keyrings/ros2-latest-archive-keyring.gpg') do it { should exist } end diff --git a/ros/rolling/ubuntu/noble/Containerfile b/ros/rolling/ubuntu/noble/Containerfile new file mode 100644 index 00000000..7be4e3a0 --- /dev/null +++ b/ros/rolling/ubuntu/noble/Containerfile @@ -0,0 +1,104 @@ +# syntax=docker/dockerfile:1 +ARG BASE_IMAGE=docker.io/ubuntu:noble-20241015 +# hadolint ignore=DL3006 +FROM ${BASE_IMAGE} AS base + +FROM base AS download + +ARG RAW_GITHUBUSERCONTENT_BASE_URL + +# download gpg key +RUN < /etc/timezone && \ + ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \ + apt-get update && \ + apt-get install -q -y --no-install-recommends tzdata && \ + rm -rf /var/lib/apt/lists/* + +# install packages +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + dirmngr \ + gnupg2 \ + && rm -rf /var/lib/apt/lists/* + +# setup sources.list +RUN echo "deb [ signed-by=/usr/share/keyrings/ros2-latest-archive-keyring.gpg ] ${ROS_PACKAGES_URI} noble main" > /etc/apt/sources.list.d/ros2-latest.list + +# setup environment +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +ENV ROSDISTRO_PKGS_SYNC_DATE=$ROSDISTRO_PKGS_SYNC_DATE +ENV ROS_DISTRO=rolling + +# install ros2 packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-rolling-ros-core=0.11.0-1* \ + && rm -rf /var/lib/apt/lists/* + +# setup entrypoint +COPY ./ros_entrypoint.sh / + +ENTRYPOINT ["/ros_entrypoint.sh"] +CMD ["bash"] + +FROM ros-core AS ros-base + +ARG RAW_GITHUBUSERCONTENT_BASE_URL + +# install bootstrap tools +RUN apt-get update && apt-get install --no-install-recommends -y \ + build-essential \ + git \ + python3-colcon-common-extensions \ + python3-colcon-mixin \ + python3-rosdep \ + python3-vcstool \ + && rm -rf /var/lib/apt/lists/* + +# bootstrap rosdep +RUN rosdep init && \ + rosdep update --rosdistro "${ROS_DISTRO}" + +# setup colcon mixin and metadata +RUN colcon mixin add default \ + "${RAW_GITHUBUSERCONTENT_BASE_URL}/colcon/colcon-mixin-repository/master/index.yaml" && \ + colcon mixin update && \ + colcon metadata add default \ + "${RAW_GITHUBUSERCONTENT_BASE_URL}/colcon/colcon-metadata-repository/master/index.yaml" && \ + colcon metadata update + +# install ros2 packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-rolling-ros-core=0.11.0-1* \ + && rm -rf /var/lib/apt/lists/* + +FROM ros-base AS perception + +# install ros2 packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-rolling-ros-base=0.11.0-1* \ + && rm -rf /var/lib/apt/lists/* + +FROM ros-base AS desktop + +# install ros2 packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-rolling-desktop=0.11.0-1* \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/ros/rolling/ubuntu/noble/docker-bake.hcl b/ros/rolling/ubuntu/noble/docker-bake.hcl new file mode 100644 index 00000000..c593318f --- /dev/null +++ b/ros/rolling/ubuntu/noble/docker-bake.hcl @@ -0,0 +1,55 @@ +variable "TAG_PREFIX" { + default = "docker.io/polymathrobotics/ros" +} + +# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux +variable "LOCAL_PLATFORM" { + default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux") +} + +variable "ROS_PACKAGE" { + default = ["ros-core", "ros-base", "perception", "desktop"] +} + +target "_common" { + args = { + ROS_PACKAGES_URI = "http://packages.ros.org/ros2/ubuntu" + RAW_GITHUBUSERCONTENT_BASE_URL = "https://raw.githubusercontent.com" + ROSDISTRO_PKGS_SYNC_DATE = "${formatdate("YYYY-MM-DD", timestamp())}" + } + dockerfile = "Containerfile" + labels = { + "org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci/blob/main/ros/jazzy/ubuntu/noble/Containerfile" + "org.opencontainers.image.licenses" = "Apache-2.0" + "org.opencontainers.image.description" = "The Robot Operating System (ROS) is an open source project for building robot applications." + "org.opencontainers.image.title" = "${TAG_PREFIX}" + "org.opencontainers.image.created" = "${timestamp()}" + "dev.polymathrobotics.image.readme-filepath" = "ros/README.md" + } +} + +target "local" { + inherits = ["_common"] + name = "local-${ros_package}" + matrix = { + ros_package = ROS_PACKAGE + } + target = ros_package + tags = [ + "${TAG_PREFIX}:rolling-${ros_package}-noble" + ] + platforms = ["${LOCAL_PLATFORM}"] +} + +target "default" { + inherits = ["_common"] + name = "default-${ros_package}" + matrix = { + ros_package = ROS_PACKAGE + } + target = ros_package + tags = [ + "${TAG_PREFIX}:rolling-${ros_package}-noble" + ] + platforms = ["linux/amd64", "linux/arm64/v8"] +} diff --git a/ros/rolling/ubuntu/noble/ros_entrypoint.sh b/ros/rolling/ubuntu/noble/ros_entrypoint.sh new file mode 100755 index 00000000..28bc65ae --- /dev/null +++ b/ros/rolling/ubuntu/noble/ros_entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +# setup ros2 environment +source "/opt/ros/$ROS_DISTRO/setup.bash" -- +exec "$@" diff --git a/ros/rolling/ubuntu/noble/test/controls/ros_rolling.rb b/ros/rolling/ubuntu/noble/test/controls/ros_rolling.rb new file mode 100644 index 00000000..482de946 --- /dev/null +++ b/ros/rolling/ubuntu/noble/test/controls/ros_rolling.rb @@ -0,0 +1,78 @@ +describe os_env('ROS_DISTRO') do + its('content') { should eq 'rolling' } +end + +describe os_env('LANG') do + its('content') { should eq 'C.UTF-8' } +end + +describe os_env('ROSDISTRO_PKGS_SYNC_DATE') do + its('content') { should match /^\d{4}-\d{2}-\d{2}$/ } +end + +describe file('/usr/share/keyrings/ros2-latest-archive-keyring.gpg') do + it { should exist } +end + +describe file('/ros_entrypoint.sh') do + it { should exist } +end + +describe command("su --login --command \"source /opt/ros/$ROS_DISTRO/setup.bash && ros2 -h\"") do + its('exit_status') { should cmp 0 } + its('stdout') { should match(/usage: ros2/) } +end + +describe file('/ros_entrypoint.sh') do + it { should exist } + its('content') { should match %r{source "/opt/ros/\$ROS_DISTRO/setup\.bash"} } +end + +# docker.io/polymathrobotics/ros:rolling-ros-core-noble +control 'ros-core' do + only_if('ros-core') do + input('test_container_image').include?('ros:rolling-ros-core-noble') + end + + %w( + colcon + rosdep + ).each do |cmd| + describe command(cmd) do + it { should_not exist } + end + end +end + +# docker.io/polymathrobotics/ros:rolling-ros-base-noble +control 'ros-base' do + only_if('ros-base') do + input('test_container_image').include?('ros:rolling-ros-base-noble') + end + + describe command('colcon') do + it { should exist } + end +end + +# docker.io/polymathrobotics/ros:rolling-perception-noble +control 'perception' do + only_if('perception') do + input('test_container_image').include?('ros:rolling-perception-noble') + end + + describe command('colcon') do + it { should exist } + end +end + +# docker.io/polymathrobotics/ros:rolling-desktop-noble +control 'desktop' do + only_if('desktop') do + input('test_container_image').include?('ros:rolling-desktop-noble') + end + + describe command('colcon') do + it { should exist } + end +end