Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2aa7487

Browse files
committedAug 17, 2023
Add actions pipeline to publish images
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
1 parent 6bce22d commit 2aa7487

File tree

4 files changed

+291
-42
lines changed

4 files changed

+291
-42
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Reusable workflows for publishing MPI Operator images.
2+
name: Build And Publish Images
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
component-name:
8+
required: true
9+
type: string
10+
platforms:
11+
required: true
12+
type: string
13+
dockerfile:
14+
required: true
15+
type: string
16+
suffix:
17+
required: false
18+
type: string
19+
context:
20+
required: false
21+
type: string
22+
load-artifact-name:
23+
required: false
24+
type: string
25+
secrets:
26+
DOCKERHUB_USERNAME:
27+
required: false
28+
DOCKERHUB_TOKEN:
29+
required: false
30+
31+
jobs:
32+
build-and-publish:
33+
name: Publish Image
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
39+
- name: Login to DockerHub
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@v2
42+
with:
43+
username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
46+
- name: Build for Component ${{ inputs.component-name }}
47+
uses: ./.github/workflows/template-publish-image
48+
with:
49+
image: docker.io/mpioperator/${{ inputs.component-name }}
50+
dockerfile: ${{ inputs.dockerfile }}
51+
platforms: ${{ inputs.platforms }}
52+
suffix: ${{ inputs.suffix }}
53+
context: ${{ inputs.context }}
54+
output-artifact-name: ${{ inputs.component-name }}${{ inputs.suffix }}
55+
load-artifact-name: ${{ inputs.load-artifact-name }}

‎.github/workflows/mpi-operator-docker-image-publish.yml

+10-42
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,14 @@ on:
1010
branches:
1111
- "master"
1212

13-
env:
14-
IMAGE_NAME: mpioperator/mpi-operator
15-
1613
jobs:
17-
build-push-docker-image:
18-
runs-on: ubuntu-latest
19-
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v3
22-
23-
- name: Docker meta
24-
id: meta
25-
uses: docker/metadata-action@v4
26-
with:
27-
images: |
28-
${{ env.IMAGE_NAME }}
29-
tags: |
30-
type=ref,event=branch
31-
type=ref,event=pr
32-
type=semver,pattern={{version}}
33-
type=semver,pattern={{major}}.{{minor}}
34-
35-
- name: Login to DockerHub
36-
if: github.event_name != 'pull_request'
37-
uses: docker/login-action@v2
38-
with:
39-
username: ${{ secrets.DOCKERHUB_USERNAME }}
40-
password: ${{ secrets.DOCKERHUB_TOKEN }}
41-
42-
- name: Docker Setup QEMU
43-
uses: docker/setup-qemu-action@v2.1.0
44-
45-
- name: Docker Setup Buildx
46-
uses: docker/setup-buildx-action@v2.2.1
47-
48-
- name: Build and push
49-
uses: docker/build-push-action@v3
50-
with:
51-
platforms: linux/amd64,linux/arm64,linux/ppc64le
52-
context: .
53-
push: ${{ github.event_name != 'pull_request' }}
54-
tags: ${{ steps.meta.outputs.tags }}
55-
labels: ${{ steps.meta.outputs.labels }}
14+
operator:
15+
name: Publish Operator Image
16+
uses: ./.github/workflows/build-and-publish-images.yaml
17+
with:
18+
component-name: mpi-operator
19+
platforms: linux/amd64,linux/arm64,linux/ppc64le
20+
dockerfile: Dockerfile
21+
secrets:
22+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
23+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: build and publish mpi test docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- "master"
12+
13+
jobs:
14+
base:
15+
name: Publish Base Image
16+
uses: ./.github/workflows/build-and-publish-images.yaml
17+
with:
18+
component-name: base
19+
platforms: linux/amd64,linux/arm64
20+
dockerfile: build/base/Dockerfile
21+
context: build/base
22+
secrets:
23+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
24+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
mpi-implementation-base:
27+
needs: base
28+
name: Publish MPI Implementation Base Images
29+
uses: ./.github/workflows/build-and-publish-images.yaml
30+
with:
31+
component-name: ${{ matrix.component-name }}
32+
platforms: ${{ matrix.platforms }}
33+
dockerfile: build/base/${{ matrix.dockerfile }}
34+
context: build/base
35+
load-artifact-name: base
36+
secrets:
37+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
38+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- component-name: openmpi
45+
platforms: linux/amd64,linux/arm64
46+
dockerfile: openmpi.Dockerfile
47+
- component-name: intel
48+
platforms: linux/amd64
49+
dockerfile: intel.Dockerfile
50+
- component-name: mpich
51+
platforms: linux/amd64,linux/arm64
52+
dockerfile: mpich.Dockerfile
53+
54+
mpi-implementation-builder:
55+
needs: mpi-implementation-base
56+
name: Publish MPI Implementation Builder Images
57+
uses: ./.github/workflows/build-and-publish-images.yaml
58+
with:
59+
component-name: ${{ matrix.component-name }}
60+
platforms: ${{ matrix.platforms }}
61+
dockerfile: build/base/${{ matrix.dockerfile }}
62+
context: build/base
63+
load-artifact-name: ${{ matrix.load-artifact-name }}
64+
secrets:
65+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
66+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
67+
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
include:
72+
- component-name: openmpi-builder
73+
platforms: linux/amd64,linux/arm64
74+
dockerfile: openmpi-builder.Dockerfile
75+
load-artifact-name: openmpi
76+
- component-name: intel-builder
77+
platforms: linux/amd64
78+
dockerfile: intel-builder.Dockerfile
79+
load-artifact-name: intel
80+
- component-name: mpich-builder
81+
platforms: linux/amd64,linux/arm64
82+
dockerfile: mpich-builder.Dockerfile
83+
load-artifact-name: mich
84+
85+
pi:
86+
needs: mpi-implementation-builder
87+
name: Publish PI example Images
88+
uses: ./.github/workflows/build-and-publish-images.yaml
89+
with:
90+
component-name: ${{ matrix.component-name }}
91+
platforms: ${{ matrix.platforms }}
92+
dockerfile: examples/v2beta1/pi/${{ matrix.dockerfile }}
93+
context: examples/v2beta1/pi
94+
suffix: ${{ matrix.suffix }}
95+
load-artifact-name: ${{ matrix.load-artifact-name }}
96+
secrets:
97+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
98+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
99+
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
include:
104+
- component-name: pi
105+
platforms: linux/amd64,linux/arm64
106+
dockerfile: Dockerfile
107+
suffix: -openmpi
108+
load-artifact-name: openmpi-builder
109+
- component-name: pi
110+
platforms: linux/amd64
111+
dockerfile: intel.Dockerfile
112+
suffix: -intel
113+
load-artifact-name: intel-builder
114+
- component-name: pi
115+
# TODO: Need to verify if mpich works on ppc64le platform.
116+
# REF: https://github.com/kubeflow/mpi-operator/issues/565
117+
platforms: linux/amd64,linux/arm64
118+
dockerfile: mpich.Dockerfile
119+
suffix: -mpich
120+
load-artifact-name: mpich-builder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Composite action to publish MPI Operator images.
2+
name: Build And Publish Container Images
3+
description: Build Multiplatform Supporting Container Images
4+
5+
inputs:
6+
image:
7+
required: true
8+
description: image tag
9+
dockerfile:
10+
required: true
11+
default: Dockerfile
12+
description: path for Dockerfile
13+
platforms:
14+
required: true
15+
description: e.g, linux/amd64
16+
suffix:
17+
required: false
18+
description: e.g, -openmpi
19+
context:
20+
required: false
21+
default: .
22+
description: e.g, build/base
23+
output-artifact-name:
24+
required: true
25+
description: e.g, mpi-operator
26+
load-artifact-name:
27+
required: false
28+
description: e.g, openmpi-builder
29+
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Setup QEMU
34+
uses: docker/setup-qemu-action@v2
35+
with:
36+
platforms: ${{ inputs.platforms }}
37+
38+
- name: Set Up Docker Buildx
39+
uses: docker/setup-buildx-action@v2
40+
41+
# - name: debug
42+
# shell: bash
43+
# run: |
44+
# docker info -f '{{ .DriverStatus }}'
45+
# cat /etc/docker/daemon.json | jq '. | .+{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json
46+
# sudo systemctl restart docker
47+
# docker info -f '{{ .DriverStatus }}'
48+
49+
- name: Docker meta
50+
if : ${{ inputs.suffix == '' }}
51+
uses: docker/metadata-action@v4
52+
with:
53+
images: ${{ inputs.image }}
54+
tags: |
55+
type=ref,event=branch
56+
type=ref,event=pr
57+
type=semver,pattern={{version}}
58+
type=semver,pattern={{major}}.{{minor}}
59+
60+
- name: Docker meta with suffix
61+
if : ${{ inputs.suffix != '' }}
62+
uses: docker/metadata-action@v4
63+
with:
64+
images: ${{ inputs.image }}
65+
tags: |
66+
type=ref,event=branch
67+
type=ref,event=pr
68+
type=semver,pattern={{version}}
69+
type=semver,pattern={{major}}.{{minor}}
70+
suffix=${{ inputs.suffix }},onlatest=true
71+
72+
- name: Download artifact
73+
if: ${{ inputs.load-artifact-name != '' }}
74+
uses: actions/download-artifact@v3
75+
with:
76+
name: ${{ inputs.load-artifact-name }}
77+
path: /tmp
78+
79+
- name: Load Image
80+
if: ${{ inputs.load-artifact-name != '' }}
81+
shell: bash
82+
run: |
83+
docker load --input /tmp/${{ inputs.load-artifact-name }}.tar
84+
docker image ls -a
85+
86+
- name: Build and Push
87+
uses: docker/build-push-action@v3
88+
with:
89+
platforms: ${{ inputs.platforms }}
90+
context: ${{ inputs.context }}
91+
file: ${{ inputs.dockerfile }}
92+
push: ${{ github.event_name != 'pull_request' }}
93+
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}
94+
labels: ${{ steps.meta.outputs.labels }}
95+
cache-from: type=gha
96+
cache-to: type=gha,mode=max
97+
outputs: type=oci,dest=/tmp/${{ inputs.output-artifact-name }}.tar
98+
build-args:
99+
port=2222
100+
BASE_LABEL=${{ env.DOCKER_METADATA_OUTPUT_TAGS }}
101+
102+
- name: Upload Artifact
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: ${{ inputs.output-artifact-name }}
106+
path: /tmp/${{ inputs.output-artifact-name }}.tar

0 commit comments

Comments
 (0)
Please sign in to comment.