Skip to content

Commit

Permalink
Build apptainer based on docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbradley committed Sep 4, 2024
1 parent 8594fb4 commit d4a4056
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 52 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/deploy-apptainer.yml

This file was deleted.

44 changes: 42 additions & 2 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Create and publish a Docker image

name: Create and publish container images

on:
release:
Expand All @@ -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
Expand Down Expand Up @@ -43,3 +44,42 @@ 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 metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- 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 }}
5 changes: 1 addition & 4 deletions apptainer.def
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Bootstrap: docker
From: condaforge/miniforge3:24.3.0-0
From: ghcr.io/imageomics/pybioclip:{{ PYBIOCLIP_VERSION }}

%arguments
PYBIOCLIP_VERSION=

%post
pip install "https://github.com/Imageomics/pybioclip/archive/refs/tags/{{ PYBIOCLIP_VERSION }}.tar.gz" && pip cache purge

%runscript
exec bash

0 comments on commit d4a4056

Please sign in to comment.