diff --git a/.github/workflows/build-and-publish-images.yaml b/.github/workflows/build-and-publish-images.yaml new file mode 100644 index 00000000..5bdad9ea --- /dev/null +++ b/.github/workflows/build-and-publish-images.yaml @@ -0,0 +1,56 @@ +# Reusable workflows for publishing MPI Operator images. +name: Build And Publish Images + +on: + workflow_call: + inputs: + component-name: + required: true + type: string + platforms: + required: true + type: string + dockerfile: + required: false + default: Dockerfile + type: string + suffix: + required: false + type: string + context: + required: false + type: string + load-artifact-name: + required: false + type: string + secrets: + DOCKERHUB_USERNAME: + required: false + DOCKERHUB_TOKEN: + required: false + +jobs: + build-and-publish: + name: Publish Image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build for Component ${{ inputs.component-name }} + uses: ./.github/workflows/template-publish-image + with: + image: docker.io/mpioperator/${{ inputs.component-name }} + dockerfile: ${{ inputs.dockerfile }} + platforms: ${{ inputs.platforms }} + suffix: ${{ inputs.suffix }} + context: ${{ inputs.context }} + output-artifact-name: ${{ inputs.component-name }}${{ inputs.suffix }} + load-artifact-name: ${{ inputs.load-artifact-name }} diff --git a/.github/workflows/mpi-operator-docker-image-publish.yml b/.github/workflows/mpi-operator-docker-image-publish.yml index 943dae44..24f64c5a 100644 --- a/.github/workflows/mpi-operator-docker-image-publish.yml +++ b/.github/workflows/mpi-operator-docker-image-publish.yml @@ -10,46 +10,14 @@ on: branches: - "master" -env: - IMAGE_NAME: mpioperator/mpi-operator - jobs: - build-push-docker-image: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: | - ${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker Setup QEMU - uses: docker/setup-qemu-action@v2.1.0 - - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v2.2.1 - - - name: Build and push - uses: docker/build-push-action@v3 - with: - platforms: linux/amd64,linux/arm64,linux/ppc64le - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + operator: + name: Publish Operator Image + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: mpi-operator + platforms: linux/amd64,linux/arm64,linux/ppc64le + dockerfile: Dockerfile + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/publish-test-images.yaml b/.github/workflows/publish-test-images.yaml new file mode 100644 index 00000000..484034f4 --- /dev/null +++ b/.github/workflows/publish-test-images.yaml @@ -0,0 +1,120 @@ +name: build and publish mpi test docker image + +on: + push: + branches: + - "master" + tags: + - "v*" + pull_request: + branches: + - "master" + +jobs: + base: + name: Publish Base Image + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: base + platforms: linux/amd64,linux/arm64 +# dockerfile: build/base/Dockerfile + context: build/base + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + mpi-implementation-base: + needs: base + name: Publish MPI Implementation Base Images + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: ${{ matrix.component-name }} + platforms: ${{ matrix.platforms }} + dockerfile: build/base/${{ matrix.dockerfile }} + context: build/base + load-artifact-name: base + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + strategy: + fail-fast: false + matrix: + include: + - component-name: openmpi + platforms: linux/amd64,linux/arm64 + dockerfile: openmpi.Dockerfile + - component-name: intel + platforms: linux/amd64 + dockerfile: intel.Dockerfile + - component-name: mpich + platforms: linux/amd64,linux/arm64 + dockerfile: mpich.Dockerfile + + mpi-implementation-builder: + needs: mpi-implementation-base + name: Publish MPI Implementation Builder Images + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: ${{ matrix.component-name }} + platforms: ${{ matrix.platforms }} + dockerfile: build/base/${{ matrix.dockerfile }} + context: build/base + load-artifact-name: ${{ matrix.load-artifact-name }} + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + strategy: + fail-fast: false + matrix: + include: + - component-name: openmpi-builder + platforms: linux/amd64,linux/arm64 + dockerfile: openmpi-builder.Dockerfile + load-artifact-name: openmpi + - component-name: intel-builder + platforms: linux/amd64 + dockerfile: intel-builder.Dockerfile + load-artifact-name: intel + - component-name: mpich-builder + platforms: linux/amd64,linux/arm64 + dockerfile: mpich-builder.Dockerfile + load-artifact-name: mich + + pi: + needs: mpi-implementation-builder + name: Publish PI example Images + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: ${{ matrix.component-name }} + platforms: ${{ matrix.platforms }} + dockerfile: examples/v2beta1/pi/${{ matrix.dockerfile }} + context: examples/v2beta1/pi + suffix: ${{ matrix.suffix }} + load-artifact-name: ${{ matrix.load-artifact-name }} + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + strategy: + fail-fast: false + matrix: + include: + - component-name: pi + platforms: linux/amd64,linux/arm64 + dockerfile: Dockerfile + suffix: -openmpi + load-artifact-name: openmpi-builder + - component-name: pi + platforms: linux/amd64 + dockerfile: intel.Dockerfile + suffix: -intel + load-artifact-name: intel-builder + - component-name: pi + # TODO: Need to verify if mpich works on ppc64le platform. + # REF: https://github.com/kubeflow/mpi-operator/issues/565 + platforms: linux/amd64,linux/arm64 + dockerfile: mpich.Dockerfile + suffix: -mpich + load-artifact-name: mpich-builder diff --git a/.github/workflows/template-publish-image/action.yaml b/.github/workflows/template-publish-image/action.yaml new file mode 100644 index 00000000..abd9811b --- /dev/null +++ b/.github/workflows/template-publish-image/action.yaml @@ -0,0 +1,106 @@ +# Composite action to publish MPI Operator images. +name: Build And Publish Container Images +description: Build Multiplatform Supporting Container Images + +inputs: + image: + required: true + description: image tag + dockerfile: + required: true + default: Dockerfile + description: path for Dockerfile + platforms: + required: true + description: e.g, linux/amd64 + suffix: + required: false + description: e.g, -openmpi + context: + required: false + default: . + description: e.g, build/base + output-artifact-name: + required: true + description: e.g, mpi-operator + load-artifact-name: + required: false + description: e.g, openmpi-builder + +runs: + using: composite + steps: + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: ${{ inputs.platforms }} + + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: debug + shell: bash + run: | + docker info -f '{{ .DriverStatus }}' + cat /etc/docker/daemon.json | jq '. | .+{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json + sudo systemctl restart docker + docker info -f '{{ .DriverStatus }}' + + - name: Docker meta + if : ${{ inputs.suffix == '' }} + uses: docker/metadata-action@v4 + with: + images: ${{ inputs.image }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Docker meta with suffix + if : ${{ inputs.suffix != '' }} + uses: docker/metadata-action@v4 + with: + images: ${{ inputs.image }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + suffix=${{ inputs.suffix }},onlatest=true + + - name: Download artifact + if: ${{ inputs.load-artifact-name != '' }} + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.load-artifact-name }} + path: /tmp + + - name: Load Image + if: ${{ inputs.load-artifact-name != '' }} + shell: bash + run: | + docker load --input /tmp/${{ inputs.load-artifact-name }}.tar + docker image ls -a + + - name: Build and Push + uses: docker/build-push-action@v3 + with: + platforms: ${{ inputs.platforms }} + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=oci,dest=/tmp/${{ inputs.output-artifact-name }}.tar + build-args: + port=2222 + BASE_LABEL=${{ env.DOCKER_METADATA_OUTPUT_TAGS }} + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.output-artifact-name }} + path: /tmp/${{ inputs.output-artifact-name }}.tar