Skip to content

Commit 73c9f28

Browse files
committed
[ci] build arch-specific images natively
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
1 parent a419cc6 commit 73c9f28

2 files changed

Lines changed: 142 additions & 24 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
secrets: inherit
4545
with:
4646
version: ${{ needs.variables.outputs.version }}
47-
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}
4847

4948
e2e-test:
5049
needs: [image, variables]

.github/workflows/image.yaml

Lines changed: 142 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,15 @@ on:
2121
version:
2222
required: true
2323
type: string
24-
build_multi_arch_images:
25-
required: true
26-
type: string
2724

2825
jobs:
29-
packages:
30-
runs-on: ubuntu-latest
26+
amd64-packages:
27+
runs-on: linux-amd64-cpu4
3128
strategy:
3229
matrix:
3330
target:
34-
- ubuntu18.04-arm64
3531
- ubuntu18.04-amd64
36-
- centos7-aarch64
3732
- centos7-x86_64
38-
ispr:
39-
- ${{ github.ref_name != 'main' && !startsWith( github.ref_name, 'release-' ) }}
40-
exclude:
41-
- ispr: true
42-
target: ubuntu18.04-arm64
43-
- ispr: true
44-
target: centos7-aarch64
4533
fail-fast: false
4634

4735
steps:
@@ -69,22 +57,117 @@ jobs:
6957
name: toolkit-container-${{ matrix.target }}-${{ github.run_id }}
7058
path: ${{ github.workspace }}/dist/*
7159

72-
image:
60+
arm64-packages:
61+
runs-on: linux-arm64-cpu4
62+
strategy:
63+
matrix:
64+
target:
65+
- ubuntu18.04-arm64
66+
- centos7-aarch64
67+
fail-fast: false
68+
69+
steps:
70+
- uses: actions/checkout@v6
71+
name: Check out code
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
with:
76+
image: tonistiigi/binfmt:master
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: build ${{ matrix.target }} packages
82+
run: |
83+
sudo apt-get install -y coreutils build-essential sed git bash make
84+
echo "Building packages"
85+
./scripts/build-packages.sh ${{ matrix.target }}
86+
87+
- name: 'Upload Artifacts'
88+
uses: actions/upload-artifact@v7
89+
with:
90+
compression-level: 0
91+
name: toolkit-container-${{ matrix.target }}-${{ github.run_id }}
92+
path: ${{ github.workspace }}/dist/*
93+
94+
packaging-image:
7395
runs-on: linux-amd64-cpu4
7496
permissions:
7597
contents: read
7698
id-token: write
7799
packages: write
100+
needs:
101+
- amd64-packages
102+
- arm64-packages
103+
steps:
104+
- uses: actions/checkout@v6
105+
name: Check out code
106+
107+
- name: Calculate build vars
108+
id: vars
109+
run: |
110+
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
111+
112+
- name: Set up QEMU
113+
uses: docker/setup-qemu-action@v3
114+
with:
115+
image: tonistiigi/binfmt:master
116+
117+
- name: Set up Docker Buildx
118+
uses: docker/setup-buildx-action@v3
119+
120+
- name: Get built packages
121+
uses: actions/download-artifact@v8
122+
with:
123+
path: ${{ github.workspace }}/dist/
124+
pattern: toolkit-container-*-${{ github.run_id }}
125+
merge-multiple: true
126+
127+
- name: Login to GitHub Container Registry
128+
uses: docker/login-action@v3
129+
with:
130+
registry: ghcr.io
131+
username: ${{ github.actor }}
132+
password: ${{ secrets.GITHUB_TOKEN }}
133+
134+
- name: Setup Go Proxy
135+
id: setup-go-proxy
136+
uses: nv-gha-runners/setup-artifactory-go-proxy@main
137+
138+
- name: Build image
139+
env:
140+
IMAGE_NAME: ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/container-toolkit
141+
VERSION: ${{ inputs.version }}
142+
PUSH_ON_BUILD: "true"
143+
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }}
144+
run: |
145+
echo "${VERSION}"
146+
make -f deployments/container/Makefile build-packaging
147+
148+
application-image:
78149
strategy:
79150
matrix:
80-
target:
81-
- application
82-
- packaging
83-
needs: packages
151+
arch:
152+
- amd64
153+
- arm64
154+
runs-on: linux-${{ matrix.arch }}-cpu4
155+
permissions:
156+
contents: read
157+
id-token: write
158+
packages: write
159+
needs:
160+
- amd64-packages
161+
- arm64-packages
84162
steps:
85163
- uses: actions/checkout@v6
86164
name: Check out code
87165

166+
- name: Calculate build vars
167+
id: vars
168+
run: |
169+
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
170+
88171
- name: Set up QEMU
89172
uses: docker/setup-qemu-action@v3
90173
with:
@@ -113,11 +196,47 @@ jobs:
113196

114197
- name: Build image
115198
env:
116-
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
117-
VERSION: ${{ inputs.version }}
199+
IMAGE_NAME: ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/container-toolkit
200+
VERSION: ${{ inputs.version }}-${{ matrix.arch }}
118201
PUSH_ON_BUILD: "true"
119-
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
120202
GOPROXY: ${{ steps.setup-go-proxy.outputs.goproxy-url }}
121203
run: |
122204
echo "${VERSION}"
123-
make -f deployments/container/Makefile build-${{ matrix.target }}
205+
make -f deployments/container/Makefile build-application
206+
207+
create-manifest:
208+
needs:
209+
- application-image
210+
runs-on: linux-amd64-cpu4
211+
steps:
212+
- uses: actions/checkout@v6
213+
name: Check out code
214+
215+
- name: Calculate build vars
216+
id: vars
217+
run: |
218+
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
219+
220+
- name: Set up QEMU
221+
uses: docker/setup-qemu-action@v3
222+
with:
223+
image: tonistiigi/binfmt:master
224+
225+
- name: Set up Docker Buildx
226+
uses: docker/setup-buildx-action@v3
227+
228+
- name: Login to GitHub Container Registry
229+
uses: docker/login-action@v3
230+
with:
231+
registry: ghcr.io
232+
username: ${{ github.actor }}
233+
password: ${{ secrets.GITHUB_TOKEN }}
234+
- name: Build Manifest
235+
env:
236+
MULTIARCH_IMAGE: ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/container-toolkit:${{ inputs.version }}
237+
run: |
238+
docker manifest create \
239+
${MULTIARCH_IMAGE} \
240+
ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/container-toolkit:${{ inputs.version }}-amd64 \
241+
ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/container-toolkit:${{ inputs.version }}-arm64
242+
docker manifest push ${MULTIARCH_IMAGE}

0 commit comments

Comments
 (0)