Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate images into one single image #104

Merged
merged 5 commits into from
Apr 30, 2024
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
27 changes: 8 additions & 19 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
name: Build and Push Multi-Arch Images

# Run workflow on pushes to main branch
on:
push:
branches:
- main
workflow_dispatch:
inputs:
force:
required: false
type: boolean
default: false

jobs:
build-ws:
strategy:
matrix:
ros2_distro: [ humble, iron ]
ros2_distro: [ iron ]

name: Build and publish ros2-ws:${{ matrix.ros2_distro }}
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-ws
base_tag: ${{ matrix.ros2_distro }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

build-control:
needs: build-ws
strategy:
matrix:
ros2_distro: [ humble, iron ]

name: Build and publish ros2-control:${{ matrix.ros2_distro }}
uses: ./.github/workflows/reusable-build-push.yml
with:
workspace: ros2-control
base_tag: ${{ matrix.ros2_distro }}
dockerfile_extension: .${{ matrix.ros2_distro }}
ros_distro: ${{ matrix.ros2_distro }}
force: ${{ github.event_name == 'workflow_dispatch' && inputs.force }}
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
36 changes: 0 additions & 36 deletions .github/workflows/manual-dispatch.yml

This file was deleted.

139 changes: 86 additions & 53 deletions .github/workflows/reusable-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,93 @@ name: Reusable workflow to build and push multi-arch images
on:
workflow_call:
inputs:
workspace:
required: true
type: string
base_tag:
required: false
type: string
default: 'humble'
output_tag:
ros_distro:
required: false
type: string
dockerfile_extension:
default: "iron"
force:
required: false
type: string
type: boolean
default: false
secrets:
token:
description: 'The GitHub token passed from the caller workflow'
description: "The GitHub token passed from the caller workflow"
required: true

env:
ROS2_WS_PATH: ros2_ws

jobs:
check-version:
name: Check if the version has been updated
outputs:
has_changed: ${{ steps.check.outputs.has_changed }}
version: ${{ steps.versions.outputs.new_version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- id: versions
run: |
git show HEAD^:$ROS2_WS_PATH/VERSION.${{ inputs.ros_distro }} 2>/dev/null
if [[ $? == 0 ]]; then
PREV_VERSION=$(git show HEAD^:$ROS2_WS_PATH/VERSION.${{ inputs.ros_distro }})
else
PREV_VERSION=0.0.0
fi
NEW_VERSION=$(git show HEAD:$ROS2_WS_PATH/VERSION.${{ inputs.ros_distro }})

echo "prev_version=${PREV_VERSION}" >> $GITHUB_OUTPUT
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
shell: bash
- uses: aica-technology/.github/.github/actions/compare-versions@v0.11.0
id: check
with:
previous_version: ${{ steps.versions.outputs.prev_version }}
new_version: ${{ steps.versions.outputs.new_version }}

metadata:
needs: check-version
if: ${{ needs.check-version.outputs.has_changed == 'true' || inputs.force }}
runs-on: ubuntu-latest
name: Parse inputs
name: Metadata
outputs:
output_tag: ${{ steps.parse.outputs.output_tag }}
image_name: ${{ steps.parse.outputs.image_name }}
path: ${{ steps.parse.outputs.path }}
file: ${{ steps.parse.outputs.file }}
build_flags: ${{ steps.parse.outputs.build_flags }}
image_name: ${{ steps.ensure-image.outputs.image_name }}
image_tags: ${{ steps.tags.outputs.image_tags }}
build_flags: ${{ steps.tags.outputs.build_flags }}
git_tag: ${{ steps.tags.outputs.git_tag }}
steps:
- name: Parse inputs
id: parse
- uses: aica-technology/.github/.github/actions/ghcr-ensure-prefix@v0.6.0
id: ensure-image
with:
image_name: aica-technology/ros2-ws

- id: tags
run: |
BUILD_FLAGS=()
# parse base tag
BASE_TAG=${{ inputs.base_tag }}

BASE_TAG=${{ inputs.ros_distro }}
BUILD_FLAGS+=(--build-arg BASE_TAG=${BASE_TAG})
echo "::debug::Using base image tag ${BASE_TAG}"
# parse output tag
OUTPUT_TAG=${{ inputs.output_tag }}
if [ -z ${OUTPUT_TAG} ]; then
OUTPUT_TAG=${BASE_TAG}
fi
echo "output_tag=${OUTPUT_TAG}" >> $GITHUB_OUTPUT
echo "::debug::Generated image tag will be ${OUTPUT_TAG}"

# parse image name
IMAGE_NAME=${{ inputs.workspace }}
IMAGE_NAME=${{ github.repository_owner }}/${IMAGE_NAME//[_]/-}
echo "::debug::Generated image name will be ${IMAGE_NAME}"
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT

# parse docker path and file
WS_PATH=${{ inputs.workspace }}
WS_PATH=${WS_PATH//[-]/_}
echo "path=${WS_PATH}" >> $GITHUB_OUTPUT
FILE=${WS_PATH}/Dockerfile${{ inputs.dockerfile_extension }}
echo "file=${FILE}" >> $GITHUB_OUTPUT

VERSION_TAG="v${{ needs.check-version.outputs.version }}"
IMAGE_TAGS="${VERSION_TAG},${VERSION_TAG}-${{ inputs.ros_distro}}","${{ inputs.ros_distro}}"
GIT_TAG="${VERSION_TAG}-${{ inputs.ros_distro}}"
BUILD_FLAGS+=(--build-arg VERSION=${GIT_TAG})

echo "::debug::Using base image tag ${BASE_TAG}"
echo "Build flags: ${BUILD_FLAGS[@]}"
echo "Image tags: ${IMAGE_TAGS}"
echo "Git tag: ${GIT_TAG}"
echo "build_flags=${BUILD_FLAGS[@]}" >> $GITHUB_OUTPUT
echo "image_tags=${IMAGE_TAGS}" >> $GITHUB_OUTPUT
echo "git_tag=${GIT_TAG}" >> $GITHUB_OUTPUT

build:
needs: metadata
strategy:
matrix:
arch: [ amd64, arm64 ]
arch: [amd64, arm64]
include:
- image: ubuntu-latest
- image: buildjet-2vcpu-ubuntu-2204-arm
Expand All @@ -78,29 +100,40 @@ jobs:
steps:
- uses: actions/checkout@v3

- if: needs.metadata.outputs.path == 'ros2_ws' || needs.metadata.outputs.path == 'ros_ws'
run: |
CONFIG_PATH=${{ needs.metadata.outputs.path }}/config
- run: |
CONFIG_PATH=$ROS2_WS_PATH/config
mkdir -p ${CONFIG_PATH}
cp common/sshd_entrypoint.sh ${CONFIG_PATH}/


- uses: aica-technology/.github/.github/actions/list-add-suffixes@v0.6.1
id: merge-tags
with:
list: ${{ needs.metadata.outputs.image_tags }}
suffixes: ${{ matrix.arch }}
glue_separator: "-"

- uses: aica-technology/.github/.github/actions/ghcr-build@v0.6.1
with:
image_name: ${{ needs.metadata.outputs.image_name }}
image_tags: ${{ needs.metadata.outputs.output_tag }}-${{ matrix.arch }}
build_context_path: ${{ needs.metadata.outputs.path }}
dockerfile_path: ${{ needs.metadata.outputs.file }}
image_tags: ${{ steps.merge-tags.outputs.list }}
build_context_path: $ROS2_WS_PATH
dockerfile_path: ros2_ws/Dockerfile
build_flags: ${{ needs.metadata.outputs.build_flags }}
token: ${{ secrets.GITHUB_TOKEN }}

multi-arch:
runs-on: ubuntu-latest
name: Merge into a multi-arch image
needs: [ metadata, build ]
needs: [metadata, build]
steps:
- uses: aica-technology/.github/.github/actions/ghcr-manifest-merge@v0.6.1
with:
image_name: ${{ needs.metadata.outputs.image_name }}
image_tags: ${{ needs.metadata.outputs.output_tag }}
image_tags: ${{ needs.metadata.outputs.image_tags }}
archs: amd64,arm64
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create git tag
uses: aica-technology/.github/.github/actions/git-tag@v0.8.1
with:
tag: ${{ needs.metadata.outputs.git_tag }}
49 changes: 19 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,33 @@

![Build and Push ROS and ROS2 images](https://github.com/aica-technology/docker-images/actions/workflows/build-push.yml/badge.svg)

## Images
This repository is used to produce pre-configured and versioned Docker images with ROS 2 and `ros2_control` packages and
other dependencies pre-installed. The images can be used as workspaces for development containers or as base images for
downstream targets.

### ROS workspace (noetic)
## ROS 2 workspace (ros2-ws)

The ros_ws image provides a ROS workspace (noetic). Build it by running the
[build script](ros_ws/build.sh) while in the [ros_ws](ros_ws) directory.
The `ros2_ws` image provides a ROS 2 workspace with pre-installed ros2-control packages.

The username that should be supplied at login is `ros`.
### Deprecated images

### ROS workspace with pre-installed control libraries
1. ROS workspace (noetic): the ros_ws image provides a ROS workspace (noetic). Build it by running the
[build script](ros_ws/build.sh) while in the [ros_ws](ros_ws) directory. The username that should be supplied at
login is `ros`.

The ros_control_libraries image provides the same ROS workspace as ros_ws but
comes with the pre-installed [control libraries](https://github.com/aica-technology/control-libraries).
2. ROS workspace with pre-installed control libraries: the ros_control_libraries image provides the same ROS workspace
as ros_ws but comes with the pre-installed [control libraries](https://github.com/aica-technology/control-libraries).

### ROS2 workspace
3. ROS 2 workspace with pre-installed control libraries: the ros2_control_libraries image provides the a ROS 2 workspace
and comes with the pre-installed [control libraries](https://github.com/aica-technology/control-libraries).

Similar to the ROS workspace, the ros2_ws image provides a ROS2 workspace.
Build it by running the [build script](ros2_ws/build.sh) while
in the [ros2_ws](ros2_ws) directory. Modify the ROS2 distribution
in the script as desired.
4. ROS 2 workspace with pre-installed control libraries and modulo: the ros2_modulo image provides a ROS 2 workspace with
[modulo](https://github.com/aica-technology/modulo) already built and comes with pre-installed
[control libraries](https://github.com/aica-technology/control-libraries).

The username that should be supplied at login is `ros2`.

### ROS2 workspace with pre-installed control libraries

The ros2_control_libraries image provides the same ROS2 workspace as ros2_ws but
comes with the pre-installed [control libraries](https://github.com/aica-technology/control-libraries).

### ROS2 workspace with pre-installed control libraries and modulo

The ros2_modulo image provides a ROS2 workspace with [modulo](https://github.com/aica-technology/modulo)
already built and comes with pre-installed [control libraries](https://github.com/aica-technology/control-libraries).

### ROS2 workspace with pre-installed control libraries, modulo, and ROS2 control

The ros2_modulo_control image provides a ROS2 workspace with [modulo](https://github.com/aica-technology/modulo)
already built and comes with pre-installed [control libraries](https://github.com/aica-technology/control-libraries)
and ROS2 control packages.
5. ROS 2 workspace with pre-installed control libraries, modulo, and ROS 2 control: the ros2_modulo_control image provides
a ROS 2 workspace with [modulo](https://github.com/aica-technology/modulo) already built and comes with pre-installed
[control libraries](https://github.com/aica-technology/control-libraries) and ROS 2 control packages.

## Scripts

Expand Down
52 changes: 0 additions & 52 deletions build-local.sh

This file was deleted.

Loading