Skip to content

Commit

Permalink
Build base image in a different workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pzehner committed Feb 2, 2024
1 parent 3c14f7d commit b3e1811
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 105 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/__build_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build base images

on:
workflow_call:
inputs:
# suffix of the Docker and Singularity images
image_name_suffix:
required: false
default: main
type: string

env:
# Force the use of BuildKit for Docker
DOCKER_BUILDKIT: 1

jobs:
build_base:
runs-on: ubuntu-latest

strategy:
matrix:
backend:
- name: openmp
use_singularity: false
- name: cuda
use_singularity: true
- name: hip
use_singularity: false
- name: sycl
use_singularity: false

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with:
tool-cache: true
large-packages: false

- name: Checkout repository
uses: actions/checkout@v4

- name: Get Singularity
env:
SINGULARITY_VERSION: 3.11.2
run: |
wget https://github.com/sylabs/singularity/releases/download/v${{ env.SINGULARITY_VERSION }}/singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb
sudo apt-get install ./singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb
- name: Login in GitHub Containers Repository with Docker
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Login in GitHub Containers Repository with Singularity
run: echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io

- name: Build Docker image
run: |
docker build \
-t ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }} \
--cache-from ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_main \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--progress=plain \
docker/${{ matrix.backend.name }}
- name: Push Docker image
run: docker push ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }}

- name: Convert Docker image to Singularity
run: singularity build base.sif docker://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ inputs.image_name_suffix }}
if: ${{ matrix.backend.use_singularity }}

- name: Push Singularity image
run: singularity push base.sif oras://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_singularity_${{ inputs.image_name_suffix }}
if: ${{ matrix.backend.use_singularity }}
50 changes: 0 additions & 50 deletions .github/workflows/base_images.yaml

This file was deleted.

58 changes: 3 additions & 55 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,66 +55,14 @@ jobs:
done
build_base:
runs-on: ubuntu-latest

needs: check_docker_files

if: ${{ needs.check_docker_files.outputs.docker_files_have_changed == 'true' }}

strategy:
matrix:
backend:
- name: openmp
use_singularity: false
- name: cuda
use_singularity: true
- name: hip
use_singularity: false
- name: sycl
use_singularity: false

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with:
tool-cache: true
large-packages: false

- name: Checkout repository
uses: actions/checkout@v4

- name: Get Singularity
env:
SINGULARITY_VERSION: 3.11.2
run: |
wget https://github.com/sylabs/singularity/releases/download/v${{ env.SINGULARITY_VERSION }}/singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb
sudo apt-get install ./singularity-ce_${{ env.SINGULARITY_VERSION }}-jammy_amd64.deb
- name: Login in GitHub Containers Repository with Docker
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Login in GitHub Containers Repository with Singularity
run: echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io
uses: ./github/workflows/__build_base.yaml

- name: Build Docker image
run: |
docker build \
-t ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }} \
--cache-from ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_main \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--progress=plain \
docker/${{ matrix.backend.name }}
- name: Push Docker image
run: docker push ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }}

- name: Convert Docker image to Singularity
run: singularity build base.sif docker://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_${{ needs.check_docker_files.outputs.image_name_suffix }}
if: ${{ matrix.backend.use_singularity }}

- name: Push Singularity image
run: singularity push base.sif oras://ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.name }}_singularity_${{ needs.check_docker_files.outputs.image_name_suffix }}
if: ${{ matrix.backend.use_singularity }}
with:
image_name_suffix: ${{ needs.check_docker_files.outputs.image_name_suffix }}

build:
runs-on: ubuntu-latest
Expand Down

0 comments on commit b3e1811

Please sign in to comment.