Add multiarch runtime image build #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: buildah-build-builder | |
on: | |
schedule: | |
- cron: "19 19 * * 0" # 19:19 UTC every Sunday | |
push: | |
paths: | |
- .github/workflows/buildah-build-builder.yml # Self-trigger | |
- containers/esmini-builder/Dockerfile | |
workflow_dispatch: | |
inputs: | |
esmini_version: | |
description: ESMINI_VERSION | |
type: string | |
required: true | |
default: v2.45.1 | |
env: | |
REGISTRY: ghcr.io/bounverif | |
IMAGE_NAME: esmini | |
ESMINI_VERSION: v2.45.1 | |
# CONTAINERS_ROOT: /home/runner/.local/share/containers | |
# TMPDIR: /home/runner/.local/share/containers/tmp | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
buildah-build: | |
name: Build container images | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-24.04, ubuntu-24.04-arm] | |
runs-on: ${{ matrix.os }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} | |
cancel-in-progress: true | |
steps: | |
- name: Install container tools | |
run: sudo apt-get install podman buildah jq | |
# - name: Maximize build space | |
# uses: easimon/maximize-build-space@v10 | |
# with: | |
# root-reserve-mb: 2048 # Reserve disk space for repository | |
# remove-dotnet: "true" | |
# remove-android: "true" | |
# remove-haskell: "true" | |
# remove-codeql: "true" | |
# remove-docker-images: "true" | |
# build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build | |
# - run: mkdir -p $TMPDIR | |
- name: Set platform tag | |
run: | | |
arch=$(podman info --format='{{.Host.Arch}}') | |
platform=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g') | |
echo "PODMAN_ARCH=${arch}" >> $GITHUB_ENV | |
echo "PLATFORM=${platform}" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the GitHub Container registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build builder container image | |
id: build-builder | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
context: ./containers | |
image: esmini | |
tags: ${{ env.ESMINI_VERSION }}-builder ${{ env.ESMINI_VERSION }}-builder-${{ env.PODMAN_ARCH }} | |
layers: true | |
oci: true | |
build-args: | | |
ESMINI_VERSION=${{ env.ESMINI_VERSION }} | |
extra-args: | | |
--target esmini-builder | |
containerfiles: | | |
./containers/esmini-builder/Dockerfile | |
- name: Build devel container image | |
id: build-devel | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
context: ./containers | |
image: esmini | |
tags: ${{ env.ESMINI_VERSION }}-devel ${{ env.ESMINI_VERSION }}-devel-${{ env.PODMAN_ARCH }} | |
layers: true | |
oci: true | |
build-args: | | |
ESMINI_VERSION=${{ env.ESMINI_VERSION }} | |
extra-args: | | |
--target esmini-devel | |
containerfiles: | | |
./containers/esmini-builder/Dockerfile | |
- name: Push to GitHub Container Repository | |
if: github.ref == 'refs/heads/multiarch-image' | |
id: push-builder-ghcr | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ steps.build-builder.outputs.image }} | |
tags: ${{ steps.build-builder.outputs.tags }} | |
digestfile: ${{ runner.temp }}/digest-esmini-builder-${{ env.PLATFORM }} | |
- name: Push to GitHub Container Repository | |
if: github.ref == 'refs/heads/multiarch-image' | |
id: push-devel-ghcr | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ steps.build-devel.outputs.image }} | |
tags: ${{ steps.build-devel.outputs.tags }} | |
digestfile: ${{ runner.temp }}/digest-esmini-devel-${{ env.PLATFORM }} | |
- name: Upload digests | |
if: github.ref == 'refs/heads/multiarch-image' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digest-esmini-${{ env.ESMINI_VERSION }}-${{ env.PLATFORM }} | |
path: ${{ runner.temp }}/digest-* | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 0 # no compression | |
buildah-merge: | |
name: Merge container images | |
runs-on: ubuntu-24.04 | |
needs: buildah-build | |
if: github.ref == 'refs/heads/multiarch-image' | |
steps: | |
# - run: mkdir -p $TMPDIR | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ runner.temp }}/digests | |
pattern: digest-* | |
merge-multiple: true | |
- name: Log in to the GitHub Container registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get the latest version | |
run: echo "ESMINI_LATEST_VERSION=$(curl -sL "https://api.github.com/repos/esmini/esmini/releases/latest" | jq -r '.tag_name')" >> $GITHUB_ENV | |
- name: Create and push manifest list for esmini-builder | |
run: | | |
MANIFEST=esmini-builder | |
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
buildah manifest create $MANIFEST | |
for digest in ${{ runner.temp }}/digests/digest-esmini-builder-*; do | |
echo "Adding $(cat $digest)" | |
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest) | |
done | |
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.ESMINI_VERSION }}-builder | |
if [ "${{ env.ESMINI_VERSION }}" == "${{ env.ESMINI_LATEST_VERSION }}" ]; then | |
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-builder | |
fi | |
- name: Create and push manifest list for esmini-builder | |
run: | | |
MANIFEST=esmini-devel | |
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
buildah manifest create $MANIFEST | |
for digest in ${{ runner.temp }}/digests/digest-esmini-devel-*; do | |
echo "Adding $(cat $digest)" | |
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest) | |
done | |
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.ESMINI_VERSION }}-devel | |
if [ "${{ env.ESMINI_VERSION }}" == "${{ env.ESMINI_LATEST_VERSION }}" ]; then | |
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-devel | |
fi |