Skip to content

Merge branch 'wrapper-refactor-migration' into 'main' #68

Merge branch 'wrapper-refactor-migration' into 'main'

Merge branch 'wrapper-refactor-migration' into 'main' #68

Workflow file for this run

name: Build Docker images
on:
push:
branches: ["main"]
tags: ["v*"]
concurrency: docker
env:
REGISTRY: ghcr.io
REGISTRY_IMAGE: educelab/pgs-recon
permissions:
id-token: write
contents: read
packages: write
jobs:
build_platform_images:
name: Build platform images
strategy:
fail-fast: false
matrix:
include:
- architecture: "amd64"
base_image: "ubuntu:22.04"
use_cuda: "OFF"
tag_suffix: ""
- architecture: "amd64"
base_image: "nvidia/cuda:12.4.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.4"
- architecture: "amd64"
base_image: "nvidia/cuda:12.8.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.8"
- architecture: "arm64"
base_image: "ubuntu:22.04"
use_cuda: "OFF"
tag_suffix: ""
- architecture: "arm64"
base_image: "nvidia/cuda:12.4.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.4"
- architecture: "arm64"
base_image: "nvidia/cuda:12.8.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.8"
runs-on: ${{ fromJSON('["ubuntu-22.04", "ubuntu-22.04-arm"]')[contains(matrix.architecture, 'arm')] }}
steps:
- name: Clean up disk space
run: |
# Space usage before cleanup
df -h /
# Remove unused tool caches (comment any required ones with #)
sudo rm -rf /usr/lib/jvm
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/swift
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Verify gains
df -h /
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
build-args: |
BASE_IMAGE=${{ matrix.base_image }}
USE_CUDA=${{ matrix.use_cuda }}
platforms: linux/${{ matrix.architecture }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests${{ matrix.tag_suffix }}
digest="${{ steps.push.outputs.digest }}"
touch "${{ runner.temp }}/digests${{ matrix.tag_suffix }}/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.architecture }}-${{ matrix.tag_suffix }}
path: ${{ runner.temp }}/digests${{ matrix.tag_suffix }}/*
if-no-files-found: error
retention-days: 1
merge_platform_images:
name: Merge platform images
needs: build_platform_images
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- base_image: "ubuntu:22.04"
use_cuda: "OFF"
tag_suffix: ""
- base_image: "nvidia/cuda:12.4.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.4"
- base_image: "nvidia/cuda:12.8.1-devel-ubuntu22.04"
use_cuda: "ON"
tag_suffix: "-cuda12.8"
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests${{ matrix.tag_suffix }}
pattern: digests-*-${{ matrix.tag_suffix }}
merge-multiple: true
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}
flavor: |
suffix=${{ matrix.tag_suffix }},onlatest=true
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=edge
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests${{ matrix.tag_suffix }}
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect Image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}