forked from uw-psych/hyakvnc_apptainer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
187 additions
and
164 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Singularity Build | ||
on: | ||
push: | ||
tags: | ||
- sif-* | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
name: Build Apptainer image | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Install Apptainer | ||
run: deb=$(curl -w "%{filename_effective}" -LO https://github.com/apptainer/apptainer/releases/download/v1.2.4/apptainer_1.2.4_amd64.deb) && sudo apt install -y "./$deb"; rm -f "$deb"; unset deb | ||
- name: Check out code for the container build | ||
uses: actions/checkout@v4 | ||
- name: Build Container | ||
run: | | ||
cont_name="${GITHUB_REF_NAME#sif-}" | ||
echo "Container name is ${cont_name:-}." | ||
[ -d "${cont_name:-}" ] || exit 1 | ||
pushd "${cont_name}" && apptainer build --fakeroot --fix-perms --warn-unused-build-args --build-arg ORAS_REPO="${{ github.repository }}" ../${cont_name}.sif Singularity && popd | ||
tag="${tag:-latest}" | ||
echo "Tag is $tag." | ||
echo "tag=$tag" >> $GITHUB_ENV | ||
echo "cont_name=$cont_name" >> $GITHUB_ENV | ||
popd | ||
- name: Login and Deploy Container | ||
run: | | ||
[ -r "${cont_name}.sif" ] || exit 1 | ||
apptainer remote login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io | ||
apptainer push "${cont_name}.sif" oras://ghcr.io/${{ github.repository }}/${cont_name}:${tag} | ||
rm -f "${cont_name}.sif" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Building the containers on GitHub Actions | ||
|
||
The containers are built using GitHub Actions. The workflow is defined in [`.github/workflows/apptainer-image.yml`](.github/workflows/apptainer-image.yml). | ||
|
||
The workflow is triggered on every push with the tag `sif-<containername>`. It builds the named container and pushes it to the GitHub Container Registry. | ||
|
||
Before containers that depend on other containers can be built, the dependent containers must be built and pushed to the registry. So, if `ubuntu22.04_turbovnc` depends on `ubuntu22.04_interactive`, you must first push a commit with the tag `sif-ubuntu22.04_interactive` for it to be built. Then, you can push a commit with the tag `sif-ubuntu22.04_turbovnc`. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/sh | ||
# Install FreeSurfer: | ||
|
||
export FREESURFER_VERSION="${FREESURFER_VERSION:-7.4.1}" | ||
FREESURFER_DOWNLOAD_ROOT="https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${FREESURFER_VERSION}" | ||
export FREESURFER_HOME="${FREESURFER_HOME:-/usr/local/freesurfer/${FREESURFER_VERSION}}" | ||
export FREESURFER_DOWNLOAD_URL="${FREESURFER_DOWNLOAD_URL:-}" | ||
|
||
if ! command -v curl >/dev/null 2>&1; then | ||
echo "warning: curl not found!" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${FREESURFER_DOWNLOAD_URL:-}" ]; then | ||
if command -v dpkg >/dev/null 2>&1; then | ||
# Is Debian/Ubuntu. Package filename looks like turbovnc_3.0.91_arm64.deb | ||
arch="$(dpkg --print-architecture)" | ||
if [ -r /etc/os-release ]; then | ||
. /etc/os-release | ||
elif [ -r /usr/lib/os-release ]; then | ||
. /usr/lib/os-release | ||
else | ||
echo >&2 "error: cannot determine OS release" | ||
exit 1 | ||
fi | ||
|
||
case "${ID:-} ${ID_LIKE:-}" in | ||
*ubuntu*) echo "Running on an Ubuntu-like platform, using Ubuntu .deb packages" ;; | ||
*) | ||
echo >&2 "Error: Must be Ubuntu-like" | ||
exit 1 | ||
;; | ||
esac | ||
ubuntu_major_version="${VERSION_ID%%.*}" | ||
[ -z "${ubuntu_major_version:-}" ] && { | ||
echo >&2 "error: cannot determine Ubuntu major version" | ||
exit 1 | ||
} | ||
filename="freesurfer_ubuntu${ubuntu_major_version}-${FREESURFER_VERSION}_${arch}.deb" | ||
elif command -v yum >/dev/null 2>&1; then | ||
# Is RHEL/CentOS/Rocky. Package filename looks like turbovnc-3.0.91.x86_64.rpm | ||
arch="$(uname -m)" | ||
if [ -r /etc/os-release ]; then | ||
. /etc/os-release | ||
elif [ -r /usr/lib/os-release ]; then | ||
. /usr/lib/os-release | ||
else | ||
echo >&2 "error: cannot determine OS release" | ||
exit 1 | ||
fi | ||
|
||
case "${ID:-} ${ID_LIKE:-}" in | ||
*rhel* | *centos* | *fedora* | *rocky*) echo "Running on an CentOS-like platform, using CentOS .rpm packages" ;; | ||
*) | ||
echo >&2 "Error: Must be CentOS-like" | ||
exit 1 | ||
;; | ||
esac | ||
centos_major_version="${VERSION_ID%%.*}" | ||
[ -z "${centos_major_version:-}" ] && { | ||
echo >&2 "error: cannot determine CentOS major version" | ||
exit 1 | ||
} | ||
filename="freesurfer_CentOS${centos_major_version}-${FREESURFER_VERSION}.${arch}.rpm" | ||
else | ||
echo >&2 "error: cannot determine architecture and package extension for this OS" | ||
exit 1 | ||
fi | ||
FREESURFER_DOWNLOAD_URL="${FREESURFER_DOWNLOAD_ROOT}/${filename}" | ||
fi | ||
|
||
echo "Downloading ${TURBOVNC_DOWNLOAD_URL}..." | ||
dlpath=$(curl -w "%{filename_effective}" -fLO "${TURBOVNC_DOWNLOAD_URL}") | ||
trap 'rm -f "${dlpath:-}"' INT QUIT TERM EXIT | ||
|
||
if [ -r "${dlpath}" ]; then | ||
if command -v dpkg >/dev/null 2>&1; then | ||
# Is Debian/Ubuntu | ||
dpkg --install --force-depends "${dlpath:-}" && apt-get install --fix-broken --yes --quiet && export success=1 || echo >&2 "warning: failed to install ${dlpath} via yum" | ||
elif command -v yum >/dev/null 2>&1; then | ||
# Is RHEL/CentOS/Rocky | ||
yum install -y -q "${dlpath}" && export success=1 || echo >&2 "warning: failed to install ${dlpath} via yum" | ||
else | ||
echo >&2 "Cannot determine package manager for this OS" | ||
fi | ||
fi | ||
|
||
[ -n "${success:-}" ] && exit 0 || exit 1 |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.