Skip to content

Containers

Containers #993

Workflow file for this run

name: Containers
on:
# This Workflow can be triggered manually
workflow_dispatch:
# Build container images on a daily schedule
schedule:
- cron: '11 5 * * *'
push:
branches:
- main
pull_request:
branches:
- main
# Let's also build & tag Spack containers on releases.
release:
types: [published]
concurrency:
group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
cancel-in-progress: true
jobs:
deploy-images:
timeout-minutes: 600
runs-on: self-hosted
permissions:
packages: write
strategy:
# Even if one container fails to build we still want the others
# to continue their builds.
fail-fast: false
# 0: image name
# 1: Dockerfile path
# 2: Platforms to build
matrix:
dockerfile: [[e4s-ubuntu-18.04, e4s-ubuntu-18.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
[e4s-ubuntu-20.04, e4s-ubuntu-20.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
[ubuntu-22.04, ubuntu-22.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
[ubuntu-24.04, ubuntu-24.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
[linux-ubuntu22.04-x86_64_v2, linux-ubuntu22.04-x86_64_v2/Dockerfile, 'linux/amd64'],
[tutorial-ubuntu-22.04, tutorial-ubuntu-22.04/Dockerfile, 'linux/amd64'],
[e4s-amazonlinux-2, e4s-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64'],
[e4s-centos-7, e4s-centos-7.dockerfile, 'linux/amd64'],
[e4s-fedora-36, e4s-fedora-36.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
[pcluster-amazonlinux-2, pcluster-amazonlinux-2/Dockerfile, 'linux/amd64,linux/arm64']]
name: Build ${{ matrix.dockerfile[0] }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Container Tag
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/spack/${{ matrix.dockerfile[0] }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Deploy ${{ matrix.dockerfile[1] }}
uses: docker/build-push-action@v5
with:
file: Dockerfiles/${{ matrix.dockerfile[1] }}
platforms: ${{ matrix.dockerfile[2] }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
ghcr.io/spack/${{ matrix.dockerfile[0] }}:nightly
ghcr.io/spack/${{ matrix.dockerfile[0] }}:main
ghcr.io/spack/${{ matrix.dockerfile[0] }}:latest
${{ steps.meta.outputs.tags }}
cache-to: type=inline
secrets: |
"bootstrap_gcc_key=${{ secrets.BOOTSTRAP_GCC_KEY }}"
upload-gcc-buildcache:
timeout-minutes: 60
runs-on: self-hosted
permissions:
packages: write
needs: [ deploy-images ]
env:
CONTAINER_NAME: 'ghcr.io/spack/pcluster-amazonlinux-2'
KEY_FINGERPRINT: '5195AD463E705FC2014BFF08FE8754F9EEC75620'
steps:
- name: Get Container Tag
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.CONTAINER_NAME }}
- name: Checkout Container
uses: actions/checkout@v4
- name: Copy from container to local disk
env:
CONTAINER_TAG: ${{ steps.meta.outputs.tags }}
run: |
id=$(docker create --platform linux/amd64 ${CONTAINER_TAG})
docker cp $id:/bootstrap-gcc-cache/build_cache/_pgp/${KEY_FINGERPRINT}.pub ${KEY_FINGERPRINT}.pub
docker rm -v $id
- name: Upload public key to Github artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.KEY_FINGERPRINT }}.pub
path: ${{ env.KEY_FINGERPRINT }}.pub