Skip to content

Commit 8bd83a8

Browse files
authored
Enable multi-arch builds (#417)
1 parent 939e1dc commit 8bd83a8

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

.github/workflows/cnf-test-partner-image.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ jobs:
5353
with:
5454
ref: main
5555

56+
- name: Set up QEMU
57+
uses: docker/setup-qemu-action@v3
58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
5661
- name: Authenticate against Quay.io
5762
uses: docker/login-action@v3
5863
with:
@@ -68,6 +73,7 @@ jobs:
6873
push: true
6974
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
7075
tags: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SPECIFIC_IMAGE_TAG }}'
76+
platforms: linux/amd64,linux/arm64
7177

7278
- name: If failed to create the image, send alert msg to dev team.
7379
if: ${{ failure() }}

.github/workflows/debug-partner-image.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v4
3131

32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
3237
- name: 'Build the `debug-partner` image'
3338
run: docker build --no-cache -f Dockerfile.debug-partner -t $IMAGE_NAME:$IMAGE_TAG .
3439

@@ -78,6 +83,7 @@ jobs:
7883
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
7984
tags: ${{ steps.meta.outputs.tags }}
8085
labels: ${{ steps.meta.outputs.labels }}
86+
platforms: linux/amd64,linux/arm64
8187

8288
- name: If failed to create the image, send alert msg to dev team.
8389
if: ${{ failure() }}

test-partner/Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,26 @@ RUN \
2424
groupadd --gid $USER_GID $USERNAME \
2525
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
2626

27-
# Install Go binary
27+
# Install Go binary and set the PATH
2828
ENV \
29-
GO_BIN_TAR=go1.22.1.linux-amd64.tar.gz \
3029
GO_DL_URL=https://golang.org/dl \
31-
GOPATH=/root/go \
32-
TEMP_DIR=/tmp
33-
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/${GO_BIN_TAR}
30+
GOPATH=/root/go
31+
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/go1.22.1.linux-amd64.tar.gz
32+
ENV GO_BIN_URL_aarch64=${GO_DL_URL}/go1.22.1.linux-arm64.tar.gz
33+
34+
# Determine the CPU architecture and download the appropriate Go binary
35+
# hadolint ignore=SC2086
3436
RUN \
3537
if [ "$(uname -m)" = x86_64 ]; then \
3638
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_x86_64} --quiet \
3739
&& rm -rf /usr/local/go \
38-
&& tar -C /usr/local -xzf ${TEMP_DIR}/${GO_BIN_TAR}; \
40+
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.22.1.linux-amd64.tar.gz; \
41+
elif [ "$(uname -m)" = aarch64 ]; then \
42+
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_aarch64} --quiet \
43+
&& rm -rf /usr/local/go \
44+
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.22.1.linux-arm64.tar.gz; \
3945
else \
40-
echo "CPU architecture not supported" && exit 1; \
46+
echo "CPU architecture is not supported." && exit 1; \
4147
fi
4248

4349
# Add go and oc binary directory to $PATH

0 commit comments

Comments
 (0)