From c3cd546f5a68d701697a885e24c2435d31bca092 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Wed, 8 May 2024 10:16:33 -0600 Subject: [PATCH] add arm64 support Issue: https://github.com/rancher/rke2/issues/5891 Signed-off-by: Michael Fritch --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ .github/workflows/image-push.yml | 9 ++++++--- Makefile | 10 ++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5711034..3d64984 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,3 +43,29 @@ jobs: if: always() with: sarif_file: 'trivy-results.sarif' + + build-arm64: + runs-on: ubuntu-latest + steps: + - name: Check out code + 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: Set the TAG value + id: get-TAG + run: | + echo "$(make -s log | grep TAG)" >> "$GITHUB_ENV" + - name: Build container image + uses: docker/build-push-action@v5 + with: + context: . + push: false + tags: rancher/hardened-node-feature-discovery:${{ env.TAG }}-arm64 + file: Dockerfile + outputs: type=docker + platforms: linux/arm64 diff --git a/.github/workflows/image-push.yml b/.github/workflows/image-push.yml index 3e41e5b..8e88118 100644 --- a/.github/workflows/image-push.yml +++ b/.github/workflows/image-push.yml @@ -15,8 +15,8 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: "Read secrets" uses: rancher-eio/read-vault-secrets@main @@ -25,6 +25,9 @@ jobs: secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ; secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Container Registry uses: docker/login-action@v3 with: @@ -38,4 +41,4 @@ jobs: push: true tags: rancher/hardened-node-feature-discovery:${{ github.event.release.tag_name }} file: Dockerfile - platforms: linux/amd64 + platforms: linux/amd64, linux/arm64 diff --git a/Makefile b/Makefile index 005ef72..8deba5f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ SEVERITIES = HIGH,CRITICAL -ifeq ($(ARCH),) -ARCH=$(shell go env GOARCH) +UNAME_M = $(shell uname -m) +ARCH= +ifeq ($(UNAME_M), x86_64) + ARCH=amd64 +else ifeq ($(UNAME_M), aarch64) + ARCH=arm64 +else + ARCH=$(UNAME_M) endif BUILD_META=-build$(shell date +%Y%m%d)