Image Creator #73
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'Image Creator' | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| minimal_version: | |
| description: 'Build Minimal Image' | |
| required: true | |
| type: boolean | |
| full_version: | |
| description: 'Build Full Image' | |
| required: true | |
| type: boolean | |
| doc_version: | |
| description: 'Build Doc Image' | |
| required: true | |
| type: boolean | |
| minimal_stable_run_id: | |
| description: 'Tag stable Minimal Image run_id=' | |
| required: false | |
| default: 0 | |
| type: number | |
| full_stable_run_id: | |
| description: 'Tag stable Full Image run_id=' | |
| required: false | |
| default: 0 | |
| type: number | |
| env: | |
| REGISTRY: 'ghcr.io' | |
| USER_NAME: 'arcaneframework' | |
| IMAGE_OS_NAME: 'ubuntu-2404' | |
| DOCKERFILE_PATH: './dockerfiles' | |
| jobs: | |
| # Quand on demande minimal et full, le minimal doit être fait avant le full. | |
| build-and-push-minimal: | |
| name: Ubuntu 24.04 Minimal Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| steps: | |
| - name: Prepare | |
| if: ${{ inputs.minimal_version }} | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| if: ${{ inputs.minimal_version }} | |
| uses: actions/checkout@v5 | |
| - name: Set up QEMU | |
| if: ${{ inputs.minimal_version }} | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: ${{ inputs.minimal_version }} | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Container registry | |
| if: ${{ inputs.minimal_version }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (labels) for Docker | |
| if: ${{ inputs.minimal_version }} | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| labels: | | |
| org.opencontainers.image.title=ArcaneFramework | |
| org.opencontainers.image.description=Minimal image to Build/Install/Run Arcane Framework | |
| - name: Build and push by digest | |
| if: ${{ inputs.minimal_version }} | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ matrix.platform }} | |
| context: ${{ env.DOCKERFILE_PATH }}/minimal | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: false | |
| outputs: | | |
| type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
| - name: Export digest | |
| if: ${{ inputs.minimal_version }} | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| if: ${{ inputs.minimal_version }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-minimal-${{ env.IMAGE_OS_NAME }}-${{ github.run_id }}-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 7 | |
| - name: Output Run ID | |
| run: echo 'Run ID is ${{ github.run_id }}' | |
| merge-minimal: | |
| name: Merge Ubuntu 24.04 Minimal Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - build-and-push-minimal | |
| steps: | |
| - name: Prepare | |
| if: ${{ inputs.minimal_version }} | |
| run: | | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Download minimal digests | |
| if: ${{ inputs.minimal_version }} | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-minimal-${{ env.IMAGE_OS_NAME }}-${{ github.run_id }}-* | |
| merge-multiple: true | |
| - name: Log in to the Container registry | |
| if: ${{ inputs.minimal_version }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| if: ${{ inputs.minimal_version }} | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags) for Docker | |
| if: ${{ inputs.minimal_version }} | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=raw, minimal_latest | |
| type=raw, gcc_minimal_latest | |
| type=raw, clang_minimal_latest | |
| - name: Create manifest list and push | |
| if: ${{ inputs.minimal_version }} | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| if: ${{ inputs.minimal_version }} | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
| build-and-push-full: | |
| name: Ubuntu 24.04 Full Image | |
| if: ${{ inputs.full_version }} | |
| needs: | |
| - merge-minimal | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| steps: | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - 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 the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| labels: | | |
| org.opencontainers.image.title=ArcaneFramework | |
| org.opencontainers.image.description=Full image to Build/Install/Run Arcane Framework | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ matrix.platform }} | |
| context: ${{ env.DOCKERFILE_PATH }}/full | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: false | |
| outputs: | | |
| type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,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-full-${{ env.IMAGE_OS_NAME }}-${{ github.run_id }}-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 7 | |
| - name: Output Run ID | |
| run: echo 'Run ID is ${{ github.run_id }}' | |
| merge-full: | |
| name: Merge Ubuntu 24.04 Full Image | |
| if: ${{ inputs.full_version }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - build-and-push-full | |
| steps: | |
| - name: Prepare | |
| run: | | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Download digests | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-full-${{ env.IMAGE_OS_NAME }}-${{ github.run_id }}-* | |
| merge-multiple: true | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=raw, full_latest | |
| type=raw, gcc_full_latest | |
| type=raw, clang_full_latest | |
| type=raw, cuda_full_latest | |
| type=raw, rocm_full_latest | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
| build-and-push-doc: | |
| name: Ubuntu 24.04 Doc Image | |
| if: ${{ inputs.doc_version }} | |
| needs: | |
| - merge-minimal | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Delete huge unnecessary tools folder | |
| run: rm -rf /opt/hostedtoolcache | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }} | |
| labels: | | |
| org.opencontainers.image.title=ArcaneFramework | |
| org.opencontainers.image.description=Doc image to Build/Install/Run Arcane Framework | |
| tags: | | |
| type=raw, doc_latest | |
| type=raw, doc_{{date 'YYYYMMDD'}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.DOCKERFILE_PATH }}/doc | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| minimal-stable: | |
| name: Tag Ubuntu 24.04 Minimal Image as stable | |
| if: ${{ inputs.minimal_stable_run_id != 0 }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Prepare | |
| run: | | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Download minimal digests | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-minimal-${{ env.IMAGE_OS_NAME }}-${{ inputs.minimal_stable_run_id }}-* | |
| merge-multiple: true | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ inputs.minimal_stable_run_id }} | |
| - name: Fail if no artifact downloaded | |
| run: | | |
| if [ ! -d "/tmp/digests" ] || [ -z "$(ls -A /tmp/digests)" ]; then | |
| echo "::error::No artifact found" | |
| exit 1 | |
| fi | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=raw, minimal_stable | |
| type=raw, minimal_{{date 'YYYYMMDD'}} | |
| type=raw, gcc_minimal_stable | |
| type=raw, clang_minimal_stable | |
| type=raw, gcc-14_minimal_{{date 'YYYYMMDD'}} | |
| type=raw, gcc-14_minimal_stable | |
| type=raw, gcc-13_minimal_{{date 'YYYYMMDD'}} | |
| type=raw, gcc-13_minimal_stable | |
| type=raw, clang-21_minimal_stable | |
| type=raw, clang-21_minimal_{{date 'YYYYMMDD'}} | |
| type=raw, clang-19_minimal_stable | |
| type=raw, clang-19_minimal_{{date 'YYYYMMDD'}} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
| full-stable: | |
| name: Tag Ubuntu 24.04 Full Image as stable | |
| if: ${{ inputs.full_stable_run_id != 0 }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Prepare | |
| run: | | |
| echo "REGISTRY_IMAGE=${{ env.REGISTRY }}/${{ env.USER_NAME }}/${{ env.IMAGE_OS_NAME }}" >> $GITHUB_ENV | |
| - name: Download full digests | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-full-${{ env.IMAGE_OS_NAME }}-${{ inputs.full_stable_run_id }}-* | |
| merge-multiple: true | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ inputs.full_stable_run_id }} | |
| - name: Fail if no artifact downloaded | |
| run: | | |
| if [ ! -d "/tmp/digests" ] || [ -z "$(ls -A /tmp/digests)" ]; then | |
| echo "::error::No artifact found" | |
| exit 1 | |
| fi | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_IMAGE }} | |
| tags: | | |
| type=raw, full_stable | |
| type=raw, full_{{date 'YYYYMMDD'}} | |
| type=raw, gcc_full_stable | |
| type=raw, clang_full_stable | |
| type=raw, cuda_full_stable | |
| type=raw, rocm_full_stable | |
| type=raw, gcc-14_full_stable | |
| type=raw, gcc-14_full_{{date 'YYYYMMDD'}} | |
| type=raw, gcc-13_full_stable | |
| type=raw, gcc-13_full_{{date 'YYYYMMDD'}} | |
| type=raw, clang-21_full_stable | |
| type=raw, clang-21_full_{{date 'YYYYMMDD'}} | |
| type=raw, clang-19_full_stable | |
| type=raw, clang-19_full_{{date 'YYYYMMDD'}} | |
| type=raw, cuda-130_full_stable | |
| type=raw, cuda-130_full_{{date 'YYYYMMDD'}} | |
| type=raw, rocm-643_full_stable | |
| type=raw, rocm-643_full_{{date 'YYYYMMDD'}} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |