Build and Push Docker and Singularity Images #4
Workflow file for this run
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
name: Build and Push Docker and Singularity Images | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag for the release' | |
required: true | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
SINGULARITY_LIBRARY_TOKEN: ${{ secrets.SINGULARITY_LIBRARY_TOKEN }} | |
DOCKER_IMAGE_NAME: opaino/genopred_pipeline | |
SINGULARITY_IMAGE_NAME: library://opain/genopred | |
IMAGE_TAG: ${{ github.ref_name }} | |
DOCKERFILE_PATH: pipeline/misc/docker/Dockerfile | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | |
- name: Build and Push Docker Image | |
run: | | |
docker buildx build --platform linux/amd64 -f $DOCKERFILE_PATH -t $DOCKER_IMAGE_NAME:latest -t $DOCKER_IMAGE_NAME:${{ github.event.inputs.tag }} --push . | |
- name: Install Singularity | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y singularity-container | |
- name: Convert Docker Image to Singularity SIF | |
run: | | |
docker pull $DOCKER_IMAGE_NAME:latest | |
singularity build ${GITHUB_WORKSPACE}/image.sif docker-daemon://${DOCKER_IMAGE_NAME}:latest | |
- name: Login to Singularity Library | |
run: echo "${{ secrets.SINGULARITY_LIBRARY_TOKEN }}" | singularity remote login --tokenfile - | |
- name: Push Singularity Image to Singularity Library | |
run: | | |
singularity push ${GITHUB_WORKSPACE}/image.sif $SINGULARITY_IMAGE_NAME:latest | |
singularity build ${GITHUB_WORKSPACE}/image_${{ github.event.inputs.tag }}.sif docker-daemon://${DOCKER_IMAGE_NAME}:${{ github.event.inputs.tag }} | |
singularity push ${GITHUB_WORKSPACE}/image_${{ github.event.inputs.tag }}.sif $SINGULARITY_IMAGE_NAME:${{ github.event.inputs.tag }} | |