Skip to content

Commit

Permalink
Add ROSDISTRO_PKGS_SYNC_DATE environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorific committed Nov 24, 2024
1 parent 86b2fec commit c3e022c
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'
Expand Down
4 changes: 3 additions & 1 deletion ros/rolling/ubuntu/jammy/Containerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions ros/rolling/ubuntu/jammy/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 4 additions & 0 deletions ros/rolling/ubuntu/jammy/test/controls/ros_rolling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
104 changes: 104 additions & 0 deletions ros/rolling/ubuntu/noble/Containerfile
Original file line number Diff line number Diff line change
@@ -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 <<EOF
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates \
curl
curl -sSL "${RAW_GITHUBUSERCONTENT_BASE_URL}/ros/rosdistro/master/ros.key" \
-o /usr/share/keyrings/ros2-latest-archive-keyring.gpg
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

# setup timezone
RUN echo 'Etc/UTC' > /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/*
55 changes: 55 additions & 0 deletions ros/rolling/ubuntu/noble/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -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"]
}
6 changes: 6 additions & 0 deletions ros/rolling/ubuntu/noble/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

# setup ros2 environment
source "/opt/ros/$ROS_DISTRO/setup.bash" --
exec "$@"
78 changes: 78 additions & 0 deletions ros/rolling/ubuntu/noble/test/controls/ros_rolling.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c3e022c

Please sign in to comment.