Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 25 additions & 8 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build and Push Docker Image (native amd64 & arm64)
on:
push:
branches: ["main", "workflow"]
pull_request:

env:
REGISTRY: ghcr.io
Expand All @@ -12,6 +13,8 @@ jobs:
build:
strategy:
matrix:
ros_distro: [humble, jazzy]
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-latest
Expand All @@ -34,20 +37,34 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image (${{ matrix.platform }})
- name: Set image tags
id: vars
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BRANCH_NAME="${{ github.head_ref }}"
SAFE_BRANCH=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "TAG=-$SAFE_BRANCH" >> $GITHUB_OUTPUT
else
echo "TAG=" >> $GITHUB_OUTPUT
fi

- name: Build and push image (${{ matrix.ros_distro }} - ${{ matrix.platform }})
uses: docker/build-push-action@v5
with:
context: .
file: ./images/ros-core.Dockerfile
file: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile
push: true
platforms: ${{ matrix.platform }}
tags: |
ghcr.io/high-flyers/ros-core:latest
ghcr.io/high-flyers/ros-core:${{ matrix.arch }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-${{ matrix.arch }}${{ steps.vars.outputs.TAG }}

manifest:
strategy:
matrix:
ros_distro: [humble, jazzy]
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
permissions:
packages: write
steps:
Expand All @@ -58,9 +75,9 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-arch manifest
- name: Create and push multi-arch manifest for ${{ matrix.ros_distro }}
run: |
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-arm64
10 changes: 7 additions & 3 deletions images/ros-core.Dockerfile → images/ros-core-humble.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Syntax: docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM ubuntu:22.04

ARG ROS_DISTRO=humble
ARG USERNAME=hf
ARG USER_UID=1000
ARG USER_UID=1001
ARG USER_GID=${USER_UID}

ENV ROS_DISTRO=humble
ENV USERNAME=${USERNAME}
ENV USER_UID=${USER_UID}
ENV USER_GID=${USER_GID}

RUN sed -i 's/# \(.*universe\)/\1/' /etc/apt/sources.list

RUN apt-get update && apt-get -y --quiet --no-install-recommends install \
Expand Down Expand Up @@ -45,6 +49,6 @@ RUN sudo apt-get update && sudo apt-get upgrade -y \
tmux \
&& sudo rm -rf /var/lib/apt/lists/*

RUN echo "source \"/opt/ros/${ROS_DISTRO}/setup.bash\"" >> "/home/${USERNAME}/.bashrc"
RUN echo "source \"/opt/ros/${ROS_DISTRO}/setup.bash\"" >> "/home/${USERNAME}/.bashrc"

CMD ["/bin/bash"]
54 changes: 54 additions & 0 deletions images/ros-core-jazzy.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Syntax: docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM ubuntu:24.04

ARG USERNAME=hf
ARG USER_UID=1001
ARG USER_GID=${USER_UID}

ENV ROS_DISTRO=jazzy
ENV USERNAME=${USERNAME}
ENV USER_UID=${USER_UID}
ENV USER_GID=${USER_GID}

RUN sed -i 's/# \(.*universe\)/\1/' /etc/apt/sources.list

RUN apt-get update && apt-get -y --quiet --no-install-recommends install \
build-essential \
cmake \
curl \
git \
python3-pip \
python3-dev \
gcc \
locales \
software-properties-common \
sudo \
&& rm -rf /var/lib/apt/lists/*


RUN locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
echo "export LANG=en_US.UTF-8" >> /etc/profile.d/locale.sh

RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" > /etc/apt/sources.list.d/ros2.list

RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd -s /bin/bash --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}

USER ${USERNAME}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN sudo apt-get update && sudo apt-get upgrade -y \
&& sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
ros-${ROS_DISTRO}-ros-base \
ros-dev-tools \
vim \
tmux \
&& sudo rm -rf /var/lib/apt/lists/*

RUN echo "source \"/opt/ros/${ROS_DISTRO}/setup.bash\"" >> "/home/${USERNAME}/.bashrc"

CMD ["/bin/bash"]
Loading