Skip to content

Commit

Permalink
Merge branch 'master' into pbrubeck/feature/fenics-bcs
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Feb 7, 2025
2 parents f4514a3 + 9650136 commit 4abd841
Show file tree
Hide file tree
Showing 14 changed files with 550 additions and 107 deletions.
180 changes: 154 additions & 26 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,189 @@ on:

jobs:
# Firedrake environment container
docker_env:
uses: ./.github/workflows/docker_reuse.yml
docker_build_env:
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
- os: macOS
platform: linux/arm64
uses: ./.github/workflows/docker_build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
target: firedrake-env
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.env
secrets: inherit

docker_merge_env:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_env
with:
target: firedrake-env
tag: ${{ inputs.tag }}
secrets: inherit

# Firedrake container (just Firedrake)
docker_vanilla:
needs: docker_env
docker_build_vanilla:
# Only run if "Build Firedrake" succeeds
if: ${{ inputs.status == 'success' }}
uses: ./.github/workflows/docker_reuse.yml
needs: docker_merge_env
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
extra-install-flags: ""
- os: macOS
platform: linux/arm64
# VTK does not have Linux ARM wheels (https://gitlab.kitware.com/vtk/vtk/-/issues/18772)
extra-install-flags: "--no-vtk"
uses: ./.github/workflows/docker_build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
extra-install-flags: ${{ matrix.extra-install-flags }}
target: firedrake-vanilla
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.vanilla
secrets: inherit
# Firedrake container (Firedrake and friends)
docker_firedrake:
# Artificial dependency on docker_complex due to CI race condition
needs: [docker_vanilla, docker_complex]
uses: ./.github/workflows/docker_reuse.yml

docker_merge_vanilla:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_vanilla
with:
target: firedrake-vanilla
tag: ${{ inputs.tag }}
secrets: inherit

# Complex Firedrake container (just Firedrake)
docker_build_complex:
needs: docker_merge_env
# Only run if "Build Firedrake" succeeds
if: ${{ inputs.status == 'success' }}
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
extra-install-flags: ""
- os: macOS
platform: linux/arm64
# VTK does not have Linux ARM wheels (https://gitlab.kitware.com/vtk/vtk/-/issues/18772)
extra-install-flags: "--no-vtk"
uses: ./.github/workflows/docker_build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
extra-install-flags: ${{ matrix.extra-install-flags }}
target: firedrake-complex
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.complex
secrets: inherit

docker_merge_complex:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_complex
with:
target: firedrake-complex
tag: ${{ inputs.tag }}
secrets: inherit

# # Firedrake container (Firedrake and friends)
docker_build_firedrake:
# Only run if "Build Firedrake" succeeds
if: ${{ inputs.status == 'success' }}
needs: docker_merge_vanilla
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
extra-install-flags: "--netgen"
- os: macOS
platform: linux/arm64
extra-install-flags: "" # no ARM wheel for netgen-mesher
uses: ./.github/workflows/docker_build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
extra-install-flags: ${{ matrix.extra-install-flags }}
target: firedrake
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.firedrake
secrets: inherit
# Firedrake container with documentation dependencies and TeX
docker_docdeps:
# Artificial dependency on docker_complex due to CI race condition
needs: [docker_vanilla, docker_complex]
uses: ./.github/workflows/docker_reuse.yml

docker_merge_firedrake:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_firedrake
with:
target: firedrake
tag: ${{ inputs.tag }}
secrets: inherit

# # Firedrake container with documentation dependencies and TeX
docker_build_docdeps:
# Only run if "Build Firedrake" succeeds
if: ${{ inputs.status == 'success' }}
needs: docker_merge_vanilla
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
- os: macOS
platform: linux/arm64
uses: ./.github/workflows/docker_build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
target: firedrake-docdeps
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.docdeps
secrets: inherit
# Firedrake complex container
docker_complex:
needs: docker_env

docker_merge_docdeps:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_docdeps
with:
target: firedrake-docdeps
tag: ${{ inputs.tag }}
secrets: inherit

# # Firedrake container with Jupyter notebooks
docker_build_jupyter:
# Only run if "Build Firedrake" succeeds
if: ${{ inputs.status == 'success' }}
uses: ./.github/workflows/docker_reuse.yml
needs: docker_merge_firedrake
strategy:
matrix:
os: [Linux, macOS]
include:
- os: Linux
platform: linux/amd64
- os: macOS
platform: linux/arm64
uses: ./.github/workflows/docker_build.yml
with:
target: firedrake-complex
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
target: firedrake-jupyter
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.complex
dockerfile: docker/Dockerfile.jupyter
secrets: inherit
# Firedrake container with Jupyter notebooks
docker_jupyter:
needs: docker_firedrake
uses: ./.github/workflows/docker_reuse.yml

docker_merge_jupyter:
uses: ./.github/workflows/docker_merge.yml
needs: docker_build_jupyter
with:
target: firedrake-jupyter
tag: ${{ inputs.tag }}
dockerfile: docker/Dockerfile.jupyter
secrets: inherit
101 changes: 101 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Reusable Docker workflow

# This workflow creates x86 or ARM images and then pushes them by digest. These
# are then combined in a separate step. See
# https://docs.docker.com/build/ci/github-actions/multi-platform/ for more information.

on:
workflow_call:
inputs:
os:
description: 'Self-hosted machine to run on'
required: true
type: string
platform:
description: 'Target docker platform (one of linux/amd64 or linux/arm64)'
required: true
type: string
target:
description: 'Target Docker image name'
required: true
type: string
tag:
description: 'Optional tag (defaults to `latest`)'
required: false
default: 'latest'
type: string
dockerfile:
description: 'Path to the Dockerfile required to build image'
required: true
type: string
extra-install-flags:
description: 'Extra args to pass when building the Dockerfile'
default: ''
required: false
type: string
secrets:
# Docker login information
DOCKERHUB_USER:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
docker_build:
name: "Build the ${{ inputs.target }} container"
strategy:
fail-fast: false
runs-on: [self-hosted, "${{ inputs.os }}"]
steps:
- name: Pre-cleanup
if: always()
run: |
rm -rf ${{ runner.temp }}/digests
- name: Add homebrew to PATH
if: inputs.os == 'macOS'
run: |
: # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
echo "/opt/homebrew/bin" >> "$GITHUB_PATH"
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push ${{ inputs.target }}
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ inputs.platform }}
file: ${{ inputs.dockerfile }}
build-args: EXTRA_INSTALL_FLAGS=${{ inputs.extra-install-flags }}
outputs: type=image,name=firedrakeproject/${{ inputs.target }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
: # Create a file in <tempdir>/digests with name matching the pushed image hash
rm -rf ${{ runner.temp }}/digests
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.imageid }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests_${{ inputs.target }}_${{ inputs.os }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

- name: Post-cleanup
if: always()
run: |
rm -rf ${{ runner.temp }}/digests
62 changes: 62 additions & 0 deletions .github/workflows/docker_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Reusable Docker workflow

# This workflow merges Linux and macOS images and pushes them to Docker.
# See https://docs.docker.com/build/ci/github-actions/multi-platform/ for more information.

on:
workflow_call:
inputs:
target:
description: 'Target docker image name to upload to'
required: true
type: string
tag:
description: 'Optional tag (defaults to `latest`)'
required: false
default: 'latest'
type: string
secrets:
# Docker login information
DOCKERHUB_USER:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
docker_merge:
runs-on: [self-hosted, Linux]
steps:
- name: Pre-cleanup
if: always()
run: |
rm -rf ${{ runner.temp }}/digests
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests_${{ inputs.target }}_*
merge-multiple: true

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Merge and push the per-platform images
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create -t firedrakeproject/${{ inputs.target }}:${{ inputs.tag }} $(printf 'firedrakeproject/${{ inputs.target }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect firedrakeproject/${{ inputs.target }}:${{ inputs.tag }}
- name: Post-cleanup
if: always()
run: |
rm -rf ${{ runner.temp }}/digests
Loading

0 comments on commit 4abd841

Please sign in to comment.