forked from maouw/infantfreesurfer-singularity
-
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
2 changed files
with
159 additions
and
0 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,93 @@ | ||
name: Apptainer Build wFSL | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
IMAGE_NAME: | ||
description: 'Name of the image to build' | ||
default: 'infant-freesurfer-wfsl' | ||
required: false | ||
IMAGE_TAG: | ||
description: 'Tag of the image to build' | ||
default: 'latest' | ||
required: false | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
APPTAINER_VERSION: 1.2.5 | ||
ORAS_VERSION: 1.1.0 | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
name: Build Apptainer image | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
steps: | ||
- name: Clear up space | ||
run: | | ||
set -eux -o pipefail | ||
sudo rm -rf /opt/hostedtoolcache /usr/share/dotnet /usr/local/lib/android /usr/share/swift /usr/local/lib/android | ||
- name: Download Apptainer | ||
run: | | ||
set -eux -o pipefail | ||
curl -o "apptainer-${APPTAINER_VERSION}.deb" -L https://github.com/apptainer/apptainer/releases/download/v${APPTAINER_VERSION}/apptainer_${APPTAINER_VERSION}_amd64.deb | ||
export DEBIAN_FRONTEND=noninteractive | ||
sudo apt-get update -yq || echo "Couldn't update apt packages. Will attempt installation without update" >&2 | ||
sudo dpkg --install --force-depends "apptainer-${APPTAINER_VERSION}.deb" && sudo apt-get install --fix-broken --yes --quiet | ||
apptainer >&2 --version && echo >&2 "Apptainer installed successfully!" | ||
apptainer remote login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io && echo "Logged in to remote registry successfully" >&2 | ||
- name: Install ORAS | ||
run: | | ||
set -eux -o pipefail | ||
curl -o "oras_${ORAS_VERSION}.tar.gz" -L "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz" | ||
# Install the executable: | ||
tar -xvf oras_${ORAS_VERSION}.tar.gz && chmod +x oras && sudo mv oras /usr/local/bin/oras | ||
sudo mv "${DOWNLOAD_PATH}" /usr/local/bin/oras && sudo chmod +x /usr/local/bin/oras & oras >&2 version && echo >&2 "oras installed successfully!" | ||
oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io && echo "Logged in to remote registry successfully" >&2 | ||
- name: Check out code for the container build | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Container | ||
run: | | ||
set -eux -o pipefail | ||
IMAGE_NAME=${{ inputs.IMAGE_NAME }} | ||
IMAGE_TAG=${{ inputs.IMAGE_TAG }} | ||
IMAGE_PATH="${GITHUB_WORKSPACE}/${IMAGE_NAME}".sif | ||
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | ||
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV | ||
echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=${IMAGE_NAME}" >&2 | ||
echo "IMAGE_TAG=${IMAGE_TAG}" >&2 | ||
echo "IMAGE_PATH=${IMAGE_PATH}" >&2 | ||
apptainer build --fix-perms --disable-cache --force "${IMAGE_PATH}" SingularitywFSL | ||
echo "Container built successfully" >&2 | ||
echo "Container size:" >&2 | ||
du -h "${IMAGE_PATH}" >&2 | ||
echo "Container labels:" >&2 | ||
apptainer inspect "${IMAGE_PATH}" >&2 | ||
- name: Push Container | ||
run: | | ||
set -eux -o pipefail | ||
# Log in: | ||
apptainer remote login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io | ||
# Push the image: | ||
apptainer push -U "${IMAGE_PATH}" oras://ghcr.io/${{ github.repository }}/${IMAGE_NAME}:${IMAGE_TAG} | ||
echo "Done" >&2 |
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,66 @@ | ||
Bootstrap: oras | ||
From: ghcr.io/uw-psych/infantfreesurfer-singularity/infantfreesurfer:latest | ||
|
||
%environment | ||
export PATH="/opt/niftyreg-master/bin:$PATH" | ||
export LD_LIBRARY_PATH="/opt/niftyreg-master/lib:$LD_LIBRARY_PATH" | ||
export FSLDIR="/opt/fsl-6.0.2" | ||
export PATH="/opt/fsl-6.0.2/bin:$PATH" | ||
export FSLOUTPUTTYPE="NIFTI_GZ" | ||
export FSLMULTIFILEQUIT="TRUE" | ||
export FSLTCLSH="/opt/fsl-6.0.2/bin/fsltclsh" | ||
export FSLWISH="/opt/fsl-6.0.2/bin/fslwish" | ||
export FSLLOCKDIR="" | ||
export FSLMACHINELIST="" | ||
export FSLREMOTECALL="" | ||
export FSLGECUDAQ="cuda.q" | ||
|
||
%post | ||
yum install -y -q \ | ||
ca-certificates \ | ||
cmake \ | ||
gcc-c++ \ | ||
git \ | ||
make | ||
yum clean all | ||
rm -rf /var/cache/yum/* | ||
mkdir -p /tmp/niftyreg/build | ||
git clone https://github.com/KCL-BMEIS/niftyreg /tmp/niftyreg/source | ||
cd /tmp/niftyreg/build | ||
cmake -DCMAKE_INSTALL_PREFIX=/opt/niftyreg-master -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF /tmp/niftyreg/source | ||
make -j1 | ||
make install | ||
ldconfig | ||
rm -rf /tmp/niftyreg | ||
|
||
yum install -y -q \ | ||
bc \ | ||
curl \ | ||
file \ | ||
libGL \ | ||
libGLU \ | ||
libICE \ | ||
libSM \ | ||
libX11 \ | ||
libXcursor \ | ||
libXext \ | ||
libXft \ | ||
libXinerama \ | ||
libXrandr \ | ||
libXt \ | ||
libgomp \ | ||
libjpeg \ | ||
libmng \ | ||
libpng12 \ | ||
nano \ | ||
openblas-serial \ | ||
sudo \ | ||
wget | ||
yum clean all | ||
rm -rf /var/cache/yum/* | ||
echo "Downloading FSL ..." | ||
mkdir -p /opt/fsl-6.0.2 | ||
curl -fL https://fsl.fmrib.ox.ac.uk/fsldownloads/fsl-6.0.2-centos6_64.tar.gz | tar -xz -C /opt/fsl-6.0.2 --strip-components 1 | ||
echo "Installing FSL conda environment ..." | ||
bash /opt/fsl-6.0.2/etc/fslconf/fslpython_install.sh -f /opt/fsl-6.0.2 | ||
|