diff --git a/.github/workflows/ramius.yml b/.github/workflows/ramius.yml new file mode 100644 index 0000000..5403297 --- /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: + 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..d85b45b 100644 --- a/Linux/development/docker/Alma9.Dockerfile +++ b/Linux/development/docker/Alma9.Dockerfile @@ -1,9 +1,11 @@ # Base -FROM almalinux:9 +ARG SEMVER_TAG=9 -#Add label for transparency -LABEL org.opencontainers.image.source https://github.com/mantidproject/dockerfiles +FROM almalinux:${SEMVER_TAG} + +# Add label for transparency +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 @@ -30,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 && \ diff --git a/utils/equate_tag_semver b/utils/equate_tag_semver new file mode 100755 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 +#