Skip to content

Build and Push Docker Images #8

Build and Push Docker Images

Build and Push Docker Images #8

name: Build and Push Docker Images
on:
push:
branches:
- main
paths:
- 'Controller/Dockerfile.gpu'
- 'worker/Dockerfile.gpu'
- 'base/Dockerfile'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
node: [base, Controller, worker]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image for Controller and worker
if: ${{ matrix.node != 'base' }}
uses: docker/build-push-action@v2
with:
context: ./${{ matrix.node }}
file: ./${{ matrix.node }}/Dockerfile.gpu
push: true
tags: ghcr.io/ecohealthalliance/slurm_reservoir:${{ matrix.node }}-gpu
cache-from: type=registry,ref=ghcr.io/ecohealthalliance/slurm_reservoir:${{ matrix.node }}-gpu
- name: Build and push base Docker image
if: ${{ matrix.node == 'base' }}
uses: docker/build-push-action@v2
with:
context: ./base
file: ./base/Dockerfile
push: true
tags: ghcr.io/ecohealthalliance/slurm_reservoir:base
cache-from: type=registry,ref=ghcr.io/ecohealthalliance/slurm_reservoir:base