Skip to content

Commit

Permalink
Enable multi-arch builds (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Apr 3, 2024
1 parent 939e1dc commit 8bd83a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cnf-test-partner-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ jobs:
with:
ref: main

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Authenticate against Quay.io
uses: docker/login-action@v3
with:
Expand All @@ -68,6 +73,7 @@ jobs:
push: true
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
tags: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SPECIFIC_IMAGE_TAG }}'
platforms: linux/amd64,linux/arm64

- name: If failed to create the image, send alert msg to dev team.
if: ${{ failure() }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/debug-partner-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 'Build the `debug-partner` image'
run: docker build --no-cache -f Dockerfile.debug-partner -t $IMAGE_NAME:$IMAGE_TAG .

Expand Down Expand Up @@ -78,6 +83,7 @@ jobs:
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

- name: If failed to create the image, send alert msg to dev team.
if: ${{ failure() }}
Expand Down
20 changes: 13 additions & 7 deletions test-partner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ RUN \
groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

# Install Go binary
# Install Go binary and set the PATH
ENV \
GO_BIN_TAR=go1.22.1.linux-amd64.tar.gz \
GO_DL_URL=https://golang.org/dl \
GOPATH=/root/go \
TEMP_DIR=/tmp
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/${GO_BIN_TAR}
GOPATH=/root/go
ENV GO_BIN_URL_x86_64=${GO_DL_URL}/go1.22.1.linux-amd64.tar.gz
ENV GO_BIN_URL_aarch64=${GO_DL_URL}/go1.22.1.linux-arm64.tar.gz

# Determine the CPU architecture and download the appropriate Go binary
# hadolint ignore=SC2086
RUN \
if [ "$(uname -m)" = x86_64 ]; then \
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_x86_64} --quiet \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf ${TEMP_DIR}/${GO_BIN_TAR}; \
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.22.1.linux-amd64.tar.gz; \
elif [ "$(uname -m)" = aarch64 ]; then \
wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_aarch64} --quiet \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf ${TEMP_DIR}/go1.22.1.linux-arm64.tar.gz; \
else \
echo "CPU architecture not supported" && exit 1; \
echo "CPU architecture is not supported." && exit 1; \
fi

# Add go and oc binary directory to $PATH
Expand Down

0 comments on commit 8bd83a8

Please sign in to comment.