2021-09-30 21:34:47 +00:00
|
|
|
name: Containers
|
2021-11-02 10:02:04 +00:00
|
|
|
|
2021-08-06 22:53:46 +00:00
|
|
|
on:
|
2021-09-30 21:34:47 +00:00
|
|
|
# This Workflow can be triggered manually
|
|
|
|
workflow_dispatch:
|
2021-08-06 22:53:46 +00:00
|
|
|
# Build new Spack develop containers nightly.
|
|
|
|
schedule:
|
|
|
|
- cron: '34 0 * * *'
|
2021-09-30 21:34:47 +00:00
|
|
|
# Run on pull requests that modify this file
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- develop
|
|
|
|
paths:
|
|
|
|
- '.github/workflows/build-containers.yml'
|
2021-12-17 09:19:21 +00:00
|
|
|
- 'share/spack/docker/*'
|
2022-10-25 11:46:47 +00:00
|
|
|
- 'share/spack/templates/container/*'
|
2022-04-22 06:51:26 +00:00
|
|
|
- 'lib/spack/spack/container/*'
|
2021-08-06 22:53:46 +00:00
|
|
|
# Let's also build & tag Spack containers on releases.
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
|
2022-06-08 22:46:46 +00:00
|
|
|
concurrency:
|
2022-09-07 18:12:57 +00:00
|
|
|
group: build_containers-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
|
2022-06-08 22:46:46 +00:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-08-06 22:53:46 +00:00
|
|
|
jobs:
|
|
|
|
deploy-images:
|
2021-10-05 23:12:25 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
packages: write
|
2021-08-06 22:53:46 +00:00
|
|
|
strategy:
|
|
|
|
# Even if one container fails to build we still want the others
|
|
|
|
# to continue their builds.
|
|
|
|
fail-fast: false
|
|
|
|
# A matrix of Dockerfile paths, associated tags, and which architectures
|
|
|
|
# they support.
|
|
|
|
matrix:
|
2022-04-22 06:51:26 +00:00
|
|
|
# Meaning of the various items in the matrix list
|
|
|
|
# 0: Container name (e.g. ubuntu-bionic)
|
|
|
|
# 1: Platforms to build for
|
|
|
|
# 2: Base image (e.g. ubuntu:18.04)
|
|
|
|
dockerfile: [[amazon-linux, 'linux/amd64,linux/arm64', 'amazonlinux:2'],
|
|
|
|
[centos7, 'linux/amd64,linux/arm64,linux/ppc64le', 'centos:7'],
|
|
|
|
[centos-stream, 'linux/amd64,linux/arm64,linux/ppc64le', 'centos:stream'],
|
|
|
|
[leap15, 'linux/amd64,linux/arm64,linux/ppc64le', 'opensuse/leap:15'],
|
|
|
|
[ubuntu-bionic, 'linux/amd64,linux/arm64,linux/ppc64le', 'ubuntu:18.04'],
|
|
|
|
[ubuntu-focal, 'linux/amd64,linux/arm64,linux/ppc64le', 'ubuntu:20.04'],
|
2023-04-28 10:28:33 +00:00
|
|
|
[ubuntu-jammy, 'linux/amd64,linux/arm64,linux/ppc64le', 'ubuntu:22.04'],
|
|
|
|
[almalinux8, 'linux/amd64,linux/arm64,linux/ppc64le', 'almalinux:8'],
|
|
|
|
[almalinux9, 'linux/amd64,linux/arm64,linux/ppc64le', 'almalinux:9'],
|
|
|
|
[rockylinux8, 'linux/amd64,linux/arm64', 'rockylinux:8'],
|
2023-06-06 15:46:53 +00:00
|
|
|
[rockylinux9, 'linux/amd64,linux/arm64', 'rockylinux:9'],
|
2023-04-28 10:28:33 +00:00
|
|
|
[fedora37, 'linux/amd64,linux/arm64,linux/ppc64le', 'fedora:37'],
|
|
|
|
[fedora38, 'linux/amd64,linux/arm64,linux/ppc64le', 'fedora:38']]
|
2021-08-06 22:53:46 +00:00
|
|
|
name: Build ${{ matrix.dockerfile[0] }}
|
2022-05-19 19:35:52 +00:00
|
|
|
if: github.repository == 'spack/spack'
|
2021-08-06 22:53:46 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-06-11 01:45:37 +00:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # @v2
|
2021-08-06 22:53:46 +00:00
|
|
|
|
|
|
|
- name: Set Container Tag Normal (Nightly)
|
|
|
|
run: |
|
2021-09-30 21:34:47 +00:00
|
|
|
container="${{ matrix.dockerfile[0] }}:latest"
|
2021-08-06 22:53:46 +00:00
|
|
|
echo "container=${container}" >> $GITHUB_ENV
|
|
|
|
echo "versioned=${container}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
# On a new release create a container with the same tag as the release.
|
|
|
|
- name: Set Container Tag on Release
|
|
|
|
if: github.event_name == 'release'
|
|
|
|
run: |
|
2021-09-30 21:34:47 +00:00
|
|
|
versioned="${{matrix.dockerfile[0]}}:${GITHUB_REF##*/}"
|
2021-08-06 22:53:46 +00:00
|
|
|
echo "versioned=${versioned}" >> $GITHUB_ENV
|
|
|
|
|
2022-04-22 06:51:26 +00:00
|
|
|
- name: Generate the Dockerfile
|
|
|
|
env:
|
|
|
|
SPACK_YAML_OS: "${{ matrix.dockerfile[2] }}"
|
2021-08-06 22:53:46 +00:00
|
|
|
run: |
|
2022-04-22 06:51:26 +00:00
|
|
|
.github/workflows/generate_spack_yaml_containerize.sh
|
|
|
|
. share/spack/setup-env.sh
|
|
|
|
mkdir -p dockerfiles/${{ matrix.dockerfile[0] }}
|
|
|
|
spack containerize --last-stage=bootstrap | tee dockerfiles/${{ matrix.dockerfile[0] }}/Dockerfile
|
|
|
|
printf "Preparing to build ${{ env.container }} from dockerfiles/${{ matrix.dockerfile[0] }}/Dockerfile"
|
|
|
|
if [ ! -f "dockerfiles/${{ matrix.dockerfile[0] }}/Dockerfile" ]; then
|
|
|
|
printf "dockerfiles/${{ matrix.dockerfile[0] }}/Dockerfile does not exist"
|
2021-08-06 22:53:46 +00:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2022-04-22 06:51:26 +00:00
|
|
|
- name: Upload Dockerfile
|
2023-01-10 10:23:13 +00:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
|
2022-04-22 06:51:26 +00:00
|
|
|
with:
|
|
|
|
name: dockerfiles
|
|
|
|
path: dockerfiles
|
|
|
|
|
2021-09-30 21:34:47 +00:00
|
|
|
- name: Set up QEMU
|
2023-06-11 18:35:42 +00:00
|
|
|
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # @v1
|
2021-09-30 21:34:47 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2023-07-01 17:57:26 +00:00
|
|
|
uses: docker/setup-buildx-action@16c0bc4a6e6ada2cfd8afd41d22d95379cf7c32a # @v1
|
2021-09-30 21:34:47 +00:00
|
|
|
|
2021-08-06 22:53:46 +00:00
|
|
|
- name: Log in to GitHub Container Registry
|
2023-06-11 18:36:31 +00:00
|
|
|
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # @v1
|
2021-08-06 22:53:46 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
2021-08-07 00:25:36 +00:00
|
|
|
username: ${{ github.actor }}
|
2021-08-06 22:53:46 +00:00
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2021-09-30 21:34:47 +00:00
|
|
|
- name: Log in to DockerHub
|
2022-05-19 19:35:52 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2023-06-11 18:36:31 +00:00
|
|
|
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # @v1
|
2021-09-30 21:34:47 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-08-06 22:53:46 +00:00
|
|
|
|
2022-04-22 06:51:26 +00:00
|
|
|
- name: Build & Deploy ${{ matrix.dockerfile[0] }}
|
2023-06-14 07:48:57 +00:00
|
|
|
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # @v2
|
2021-08-06 22:53:46 +00:00
|
|
|
with:
|
2022-04-22 06:51:26 +00:00
|
|
|
context: dockerfiles/${{ matrix.dockerfile[0] }}
|
|
|
|
platforms: ${{ matrix.dockerfile[1] }}
|
2021-09-30 21:34:47 +00:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2022-04-22 06:51:26 +00:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2021-08-06 22:53:46 +00:00
|
|
|
tags: |
|
2021-09-30 21:34:47 +00:00
|
|
|
spack/${{ env.container }}
|
|
|
|
spack/${{ env.versioned }}
|
|
|
|
ghcr.io/spack/${{ env.container }}
|
|
|
|
ghcr.io/spack/${{ env.versioned }}
|