From f395b038295f1baa403346ce2ea04612aa5da61c Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Wed, 24 Sep 2025 12:43:13 -0400 Subject: [PATCH 1/8] enable CI for docker builds with base image semantic version tracking --- .github/workflows/ramius.yml | 51 ++++++++++++++++++++++ Linux/development/docker/Alma9.Dockerfile | 6 ++- utils/equate_tag_semver | 53 +++++++++++++++++++++++ 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ramius.yml create mode 100644 utils/equate_tag_semver diff --git a/.github/workflows/ramius.yml b/.github/workflows/ramius.yml new file mode 100644 index 0000000..3004b05 --- /dev/null +++ b/.github/workflows/ramius.yml @@ -0,0 +1,51 @@ +--- + +name: ramius +on: workflow_dispatch + +jobs: + + job_setup: + runs-on: ubuntu-latest + steps: + - name: retrieve ${{ github.event.repository.name }} project + uses: actions/checkout@v4 + + - id: semver_tag + name: retrieve semantic version of latest tag + run: | + read -r semver_tag <<< $(./utils/equate_tag_semver "library/almalinux:latest") + test -n ${semver_tag} || exit 1 + echo "semver_tag=${semver_tag}" >> $GITHUB_OUTPUT + outputs: + semver_tag: ${{ steps.semver_tag.outputs.semver_tag }} + + job_docker: + if: true + runs-on: ubuntu-latest + needs: [ job_setup ] + steps: + - name: retrieve ${{ github.event.repository.name }} project + uses: actions/checkout@v4 + + - name: setup buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: build and push - mantid development image + uses: docker/build-push-action@v6 + with: + context: Linux/development/docker + file: Linux/development/docker/Alma9.Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/mantid-development-alma:${{ needs.job_setup.outputs.semver_tag }} + build-args: | + SEMVER_TAG=${{ needs.job_setup.outputs.semver_tag }} + + diff --git a/Linux/development/docker/Alma9.Dockerfile b/Linux/development/docker/Alma9.Dockerfile index 276a183..1eeb99d 100644 --- a/Linux/development/docker/Alma9.Dockerfile +++ b/Linux/development/docker/Alma9.Dockerfile @@ -1,8 +1,10 @@ # Base -FROM almalinux:9 +ARG SEMVER_TAG -#Add label for transparency +FROM almalinux:${SEMVER_TAG} + +# Add label for transparency LABEL org.opencontainers.image.source https://github.com/mantidproject/dockerfiles # Add target user diff --git a/utils/equate_tag_semver b/utils/equate_tag_semver new file mode 100644 index 0000000..4d9cf49 --- /dev/null +++ b/utils/equate_tag_semver @@ -0,0 +1,53 @@ +#!/bin/bash + +# +# retrieve and equate semantic version with given tag +# +# +# example: +# +# ./utils/equate_tag_semver "library/almalinux:latest" +# +# where "library/almalinux" is the image and "latest" is the tag +# + +image=${1%%:*} +tag=${1##*:} + +# initial URL for first page of API response +next_url="https://hub.docker.com/v2/repositories/${image}/tags/?page=1&page_size=100" + +paginated_results=() + +while [ -n "${next_url}" ]; do + # fetch data and extract next_url and paginated tags list + response=$(curl -s "${next_url}") + + # use jq to extract the next URL and append tags list + next_url=$(echo "${response}" | jq -r '.next') + + # append items from current page to the paginated_results + # jq -c means flatten JSON output into a single line + items=$(echo "${response}" | jq -c '.results') + + # append the current page's items to paginated results array + while IFS= read -r item; do + paginated_results+=("${item}") + done <<< "${items}" +done + +# +# Output the combined array of all items as a single JSON object, then flatten and filter +# to find the semantic version (x.y) tag that shares the same digest as the latest tag +# +printf '%s\n' "${paginated_results[@]}" \ + | jq -r --arg tag "${tag}" '. + | flatten | map(del(.images)) | group_by(.digest) | .[] + | select(.[].name == $tag) | .[] + | select(.name | match("^\\d+.\\d+$")) | .name + ' + +# +# +# https://stackoverflow.com/questions/28320134/how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registry +# From 72e0f1fb5772285feaa690f7ae93ed4a75599f49 Mon Sep 17 00:00:00 2001 From: Ian Gibbs Date: Wed, 24 Sep 2025 12:47:19 -0400 Subject: [PATCH 2/8] add exec perm --- utils/equate_tag_semver | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 utils/equate_tag_semver diff --git a/utils/equate_tag_semver b/utils/equate_tag_semver old mode 100644 new mode 100755 From f34d2bc5e123ff463d548e7b0791bd990d94ee15 Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Wed, 24 Sep 2025 12:59:12 -0400 Subject: [PATCH 3/8] try to force CI workflow run from non default branch --- .github/workflows/ramius.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ramius.yml b/.github/workflows/ramius.yml index 3004b05..3b25776 100644 --- a/.github/workflows/ramius.yml +++ b/.github/workflows/ramius.yml @@ -1,7 +1,13 @@ --- name: ramius -on: workflow_dispatch +on: + workflow_dispatch: + pull_request: + push: + branches: [main] + tags: ["v*"] + jobs: From 369b0f4e4d7e61226c0d22e671a8c25fcc950df5 Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:03:21 -0400 Subject: [PATCH 4/8] set default value for SEMVER_TAG argument Co-authored-by: MialLewis <95620982+MialLewis@users.noreply.github.com> --- Linux/development/docker/Alma9.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux/development/docker/Alma9.Dockerfile b/Linux/development/docker/Alma9.Dockerfile index 1eeb99d..adf5d7d 100644 --- a/Linux/development/docker/Alma9.Dockerfile +++ b/Linux/development/docker/Alma9.Dockerfile @@ -1,6 +1,6 @@ # Base -ARG SEMVER_TAG +ARG SEMVER_TAG=9 FROM almalinux:${SEMVER_TAG} From cabfd85b18a8432309bb4f8b5f47cd7d1c7dd6ca Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Fri, 3 Oct 2025 11:03:33 -0400 Subject: [PATCH 5/8] LABEL key=value should be used instead of legacy LABEL key value format Co-authored-by: MialLewis <95620982+MialLewis@users.noreply.github.com> --- Linux/development/docker/Alma9.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux/development/docker/Alma9.Dockerfile b/Linux/development/docker/Alma9.Dockerfile index adf5d7d..afb6173 100644 --- a/Linux/development/docker/Alma9.Dockerfile +++ b/Linux/development/docker/Alma9.Dockerfile @@ -5,7 +5,7 @@ ARG SEMVER_TAG=9 FROM almalinux:${SEMVER_TAG} # Add label for transparency -LABEL org.opencontainers.image.source https://github.com/mantidproject/dockerfiles +LABEL org.opencontainers.image.source=https://github.com/mantidproject/dockerfiles # Add target user RUN useradd --uid 911 --user-group --shell /bin/bash --create-home abc From 8fd1a116548936836f415cfc418a2916760ee911 Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:17:30 -0400 Subject: [PATCH 6/8] manual workflow dispatch --- .github/workflows/ramius.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ramius.yml b/.github/workflows/ramius.yml index 3b25776..a795075 100644 --- a/.github/workflows/ramius.yml +++ b/.github/workflows/ramius.yml @@ -3,11 +3,6 @@ name: ramius on: workflow_dispatch: - pull_request: - push: - branches: [main] - tags: ["v*"] - jobs: From 68eabcf94deb9a55b012a9636040f9839d766093 Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:34:24 -0400 Subject: [PATCH 7/8] set MANPATH, INFOPATH idempotently under the RUN command --- Linux/development/docker/Alma9.Dockerfile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Linux/development/docker/Alma9.Dockerfile b/Linux/development/docker/Alma9.Dockerfile index afb6173..d85b45b 100644 --- a/Linux/development/docker/Alma9.Dockerfile +++ b/Linux/development/docker/Alma9.Dockerfile @@ -32,13 +32,21 @@ COPY ./install_latex.sh /tmp/ RUN bash /tmp/install_latex.sh && \ rm -rf /latex -# Set paths for latex here and not in install_latex.sh to allow installation of anyfontsize ENV PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH -ENV MANPATH=$MANPATH:/usr/local/texlive/2025/texmf-dist/doc/man -ENV INFOPATH=$INFOPATH:/usr/local/texlive/2025/texmf-dist/doc/info -# install anyfontsize package -RUN tlmgr install anyfontsize +# Set paths for latex here and not in install_latex.sh to allow installation of anyfontsize +# +# "${MANPATH}${MANPATH:+:}" is a form of bash parameter expansion to conditionally +# append a colon only if the MANPATH variable was previously defined +# +RUN <<__EOT__ + + export MANPATH=${MANPATH}${MANPATH:+:}/usr/local/texlive/2025/texmf-dist/doc/man + export INFOPATH=${INFOPATH}${INFOPATH:+:}/usr/local/texlive/2025/texmf-dist/doc/info + + tlmgr install anyfontsize + +__EOT__ # Create source, build and external data directories. RUN mkdir -p /mantid_src && \ From 97cb65fa693ca398590e58ebb8c385e6c1715cbb Mon Sep 17 00:00:00 2001 From: Ian Gibbs <90706300+idigs@users.noreply.github.com> Date: Thu, 9 Oct 2025 08:37:06 -0400 Subject: [PATCH 8/8] remove superfluous conditional --- .github/workflows/ramius.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ramius.yml b/.github/workflows/ramius.yml index a795075..5403297 100644 --- a/.github/workflows/ramius.yml +++ b/.github/workflows/ramius.yml @@ -22,7 +22,6 @@ jobs: semver_tag: ${{ steps.semver_tag.outputs.semver_tag }} job_docker: - if: true runs-on: ubuntu-latest needs: [ job_setup ] steps: