Skip to content

Commit

Permalink
ci: fix arm64
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Yu <jack.yu@suse.com>
  • Loading branch information
Yu-Jack committed Apr 15, 2024
1 parent b0c02cb commit f271c12
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 257 deletions.
176 changes: 0 additions & 176 deletions .drone.yml

This file was deleted.

54 changes: 3 additions & 51 deletions .github/workflows/template-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ jobs:
id-token: write
container:
image: rancher/dapper:v0.5.8
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
# Git is not in Dapper container image. Add it manually for dirty check.
- name: Add Git
Expand All @@ -30,14 +24,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Arch
id: get-arch
run: |
arch=$(echo ${{ matrix.platform }} | cut -c 7-)
echo "ARCH=$arch" >> "$GITHUB_OUTPUT"

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

Expand Down Expand Up @@ -67,43 +53,9 @@ jobs:
with:
provenance: false
context: .
platforms: ${{ matrix.platform }}
platforms: linux/amd64,linux/arm64
file: package/Dockerfile
push: ${{ inputs.push }}
tags: rancher/support-bundle-kit:${{ inputs.release-tag-name }}-${{ steps.get-arch.outputs.ARCH }}
tags: rancher/support-bundle-kit:${{ inputs.release-tag-name }}
build-args: |
ARCH=${{ steps.get-arch.outputs.ARCH }}
VERSION=${{ github.ref_name }}-${{ github.sha }}-head
manifest:
if: ${{ inputs.push == true }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs:
- dapper-build
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Create Manifest arm64 and amd64
run: >
docker manifest create rancher/support-bundle-kit:${{ inputs.release-tag-name }} rancher/support-bundle-kit:${{ inputs.release-tag-name }}-amd64 rancher/support-bundle-kit:${{ inputs.release-tag-name }}-arm64
working-directory: package

- name: Push Manifest
run: docker manifest push rancher/support-bundle-kit:${{ inputs.release-tag-name }}
VERSION=${{ github.ref_name }}-${{ github.sha }}-head
10 changes: 8 additions & 2 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
FROM registry.suse.com/bci/bci-base:15.5

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \
fi

RUN zypper -n rm container-suseconnect && \
zypper -n install zip curl which tar && \
zypper -n clean -a && rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/*

ARG ARCH=amd64
ENV ARCH=${TARGETPLATFORM#linux/}
ENV TINI_VERSION v0.19.0
ENV TINI_URL_amd64=https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini \
TINI_URL_arm64=https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-arm64 \
Expand All @@ -20,7 +26,7 @@ RUN chmod +x /usr/bin/entrypoint.sh
ADD hack/support-bundle-collector.sh /usr/bin
RUN chmod +x /usr/bin/support-bundle-collector.sh

ADD bin/support-bundle-kit /usr/bin
ADD bin/support-bundle-kit-${ARCH} /usr/bin/support-bundle-kit
RUN chmod +x /usr/bin/support-bundle-kit

ADD hack/collector-* /usr/bin/
Expand Down
8 changes: 3 additions & 5 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ fi

LINKFLAGS="-X github.com/rancher/support-bundle-kit/cmd.AppVersion=$VERSION
-X github.com/rancher/support-bundle-kit/cmd.GitCommit=$COMMIT"
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/support-bundle-kit
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/support-bundle-kit-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/support-bundle-kit-windows
fi

CGO_ENABLED=0 GOARCH=amd64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/support-bundle-kit-amd64
CGO_ENABLED=0 GOARCH=arm64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/support-bundle-kit-arm64

# non-go scripts
cp hack/* bin
34 changes: 17 additions & 17 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ cd $(dirname $0)/..

mkdir -p dist/artifacts
cp bin/* dist/artifacts
mv dist/artifacts/support-bundle-kit dist/artifacts/support-bundle-kit${SUFFIX}

case $(uname -m) in
aarch64 | arm64)
ARCH=arm64
;;
x86_64)
ARCH=amd64
;;
s390x)
ARCH=s390x
;;
*)
echo "$(uname -a): unsupported architecture"
exit 1
esac

IMAGE=${REPO}/support-bundle-kit:${TAG}
DOCKERFILE=package/Dockerfile

docker run --privileged --rm tonistiigi/binfmt --install all
buildx create --platform linux/amd64,linux/arm64 --use
buildx ls

# In old docker version, it doesn't support multiple values in --platform with --load.
# So we only load image with current platform.
# Ref: https://github.com/docker/buildx/issues/59#issuecomment-616050491

# build
buildx build --platform linux/amd64,linux/arm64 \
-f ${DOCKERFILE} -t ${IMAGE} .

# test
buildx build --load \
-f ${DOCKERFILE} -t ${IMAGE} .

docker build --build-arg ARCH=${ARCH} --no-cache -f package/Dockerfile -t ${IMAGE} .
echo Built ${IMAGE}
7 changes: 1 addition & 6 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ else
VERSION="${COMMIT}${DIRTY}"
fi

if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi

SUFFIX="-${ARCH}"

TAG=${TAG:-${VERSION}${SUFFIX}}
TAG=${TAG:-${VERSION}}
REPO=${REPO:-rancher}

if echo $TAG | grep -q dirty; then
Expand Down

0 comments on commit f271c12

Please sign in to comment.