From 669399334d17087da07b7ca983caeb6e743060b4 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 12 Mar 2025 18:19:11 +0100 Subject: [PATCH] Refactor Docker workflow --- .github/workflows/docker.yml | 94 +++++++++++------------------------- contrib/docker/Dockerfile | 7 ++- 2 files changed, 32 insertions(+), 69 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b172077b9b..4174d64907 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,48 +3,41 @@ name: github-docker on: push: branches: - - 'docker*' + - "docker*" schedule: - - cron: '0 */12 * * *' + - cron: "0 */12 * * *" permissions: contents: read packages: write -env: - REGISTRY_IMAGE: dealii/dealii - jobs: build-master-docker-ubuntu: # Build images for different ubuntu versions on different platforms if: (github.event_name == 'schedule' && github.repository == 'dealii/dealii') || github.event_name != 'schedule' - name: build master docker ${{ matrix.ubuntu_version }} ${{ matrix.platform }} - runs-on: ${{ matrix.os }} + name: build master docker ${{ matrix.ubuntu_version }} ${{ matrix.architecture }} + runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: ubuntu_version: [jammy, noble] - platform: [amd64, arm64] + architecture: [amd64, arm64] include: - - platform: amd64 - os: ubuntu-24.04 - - platform: arm64 - os: ubuntu-24.04-arm + - architecture: amd64 + runs-on: ubuntu-24.04 + flags: "" + - architecture: arm64 + runs-on: ubuntu-24.04-arm + flags: -mno-outline-atomics # Use all available processors to build. # Specify the number of jobs explicitly since the default '0' # causes the github workers to disconnect (potential crash). - n_jobs: 4 steps: - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - - name: Checkout code uses: actions/checkout@v4 @@ -64,7 +57,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image of master ${{ matrix.ubuntu_version }}-${{ matrix.platform }} + - name: Build and push Docker image of master ${{ matrix.ubuntu_version }}-${{ matrix.architecture }} id: build uses: docker/build-push-action@v6 with: @@ -75,25 +68,13 @@ jobs: IMG=${{ matrix.ubuntu_version }} NJOBS=${{ matrix.n_jobs }} VER=master - platforms: linux/${{ matrix.platform }} - labels: ${{ steps.meta.outputs.labels }} - push: ${{ github.event_name == 'schedule' }} - outputs: type=image,name=ghcr.io/${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + FLAGS=${{ matrix.flags }} + platforms: linux/${{ matrix.architecture }} + tags: | + ghcr.io/dealii/dealii:master-${{ matrix.ubuntu_version }}-${{ matrix.architecture }} + dealii/dealii:master-${{ matrix.ubuntu_version }}-${{ matrix.architecture }} + push: true - - name: Export digest - run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v4 - with: - name: digests-${{ matrix.ubuntu_version }}-${{ matrix.platform }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - merge: # Merge all images for a specific ubuntu version @@ -106,25 +87,17 @@ jobs: strategy: fail-fast: false matrix: - ubuntu_version: [jammy, noble] + docker: + - ghcr.io/dealii/dealii + - dealii/dealii + ubuntu_version: + - jammy + - noble steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-${{ matrix.ubuntu_version }}-* - merge-multiple: true - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ env.REGISTRY_IMAGE }} - - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -138,18 +111,9 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Create manifest list and push to ghcr.io - working-directory: /tmp/digests - run: | - docker buildx imagetools create -t ghcr.io/${{ env.REGISTRY_IMAGE }}:master-${{ matrix.ubuntu_version }} \ - $(printf 'ghcr.io/${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Create manifest list and push to DockerHub - working-directory: /tmp/digests - run: | - docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:master-${{ matrix.ubuntu_version }} \ - $(printf 'ghcr.io/${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Inspect image + - name: Merge images of ${{ matrix.docker }}:${{ matrix.ubuntu_version }} run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:master-${{ matrix.ubuntu_version }} + docker buildx imagetools create \ + -t ${{ matrix.docker }}:master-${{ matrix.ubuntu_version }} \ + ${{ matrix.docker }}:master-${{ matrix.ubuntu_version }}-amd64 \ + ${{ matrix.docker }}:master-${{ matrix.ubuntu_version }}-arm64 diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index 7c78d7591a..961eeee8d9 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -1,11 +1,10 @@ -ARG IMG=focal # Ubuntu image that contains all corresponding dependencies. +ARG IMG=noble # Ubuntu image that contains all corresponding dependencies. FROM dealii/dependencies:$IMG ARG NJOBS=0 # Jobs used for building. Default: Use all available jobs. ARG VER=master # deal.II branch that gets checked out. - -LABEL maintainer="luca.heltai@gmail.com" +ARG FLAGS="" # Additional flags for the build. USER root @@ -18,7 +17,7 @@ RUN cd /usr/src && \ -DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu/hdf5/openmpi;/usr/include/hdf5/openmpi" \ -DDEAL_II_ALLOW_AUTODETECTION=OFF \ -DDEAL_II_COMPONENT_PYTHON_BINDINGS=ON \ - -DCMAKE_CXX_FLAGS="-std=c++17" \ + -DCMAKE_CXX_FLAGS="-std=c++20 $FLAGS" \ -DDEAL_II_WITH_64BIT_INDICES=OFF \ -DDEAL_II_WITH_ADOLC=ON \ -DDEAL_II_WITH_ARBORX=OFF \ -- 2.39.5