From 1909a17b337ba109061ed88bb428d934bb7fb3a8 Mon Sep 17 00:00:00 2001 From: John Bradley Date: Tue, 3 Sep 2024 14:52:35 -0400 Subject: [PATCH] Add apptainer support Adds apptainer definition and config to automatically build the apptainer image on release. The apptainer image is based on the docker image. Part of #27 Co-authored-by: Hilmar Lapp --- .github/workflows/deploy-image.yml | 40 ++++++++++++++++++++++++++++-- apptainer.def | 8 ++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 apptainer.def diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml index 12e2cf1..0467e0d 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/deploy-image.yml @@ -1,4 +1,5 @@ -name: Create and publish a Docker image + +name: Create and publish container images on: release: @@ -8,7 +9,7 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: + build-and-push-docker: runs-on: ubuntu-latest permissions: contents: read @@ -43,3 +44,38 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: "PYBIOCLIP_VERSION=${{ steps.meta.outputs.version }}" + + build-and-push-apptainer: + runs-on: ubuntu-latest + needs: build-and-push-docker + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version for apptainer build + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Setup apptainer executable + uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.3 + + - name: Build an apptainer image + run: apptainer build --build-arg PYBIOCLIP_VERSION=${{ steps.meta.outputs.version }} apptainer.sif apptainer.def + + - name: Publish apptainer image + run: apptainer push apptainer.sif oras://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-sif:${{ steps.meta.outputs.version }} diff --git a/apptainer.def b/apptainer.def new file mode 100644 index 0000000..18aea20 --- /dev/null +++ b/apptainer.def @@ -0,0 +1,8 @@ +Bootstrap: docker +From: ghcr.io/imageomics/pybioclip:{{ PYBIOCLIP_VERSION }} + +%arguments + PYBIOCLIP_VERSION= + +%runscript + exec "$@"