Skip to content

Commit

Permalink
Merge pull request #73 from jschintag/s390x-build
Browse files Browse the repository at this point in the history
ci: Enable building for s390x and arm64
  • Loading branch information
kubevirt-bot authored Dec 3, 2024
2 parents af83c10 + 5a625eb commit c2d9ba6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/image-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ on:
env:
image-push-owner: 'kubevirt'
jobs:
push-amd64:
name: Image push/amd64
push:
name: Image push
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

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

- name: Login to Container Registry
if: github.repository_owner == 'kubevirt'
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -38,9 +38,10 @@ jobs:

- name: Push latest container image
if: github.repository_owner == 'kubevirt'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/s390x,linux/arm64
push: true
tags: ghcr.io/${{ env.REPOSITORY_LC }}:latest
file: Dockerfile
Expand All @@ -49,9 +50,10 @@ jobs:
- name: Push tagged container image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v2
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/s390x,linux/arm64
push: true
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ github.ref_name }}
file: Dockerfile
Expand All @@ -63,7 +65,7 @@ jobs:
run: IMAGE=ghcr.io/${{ env.REPOSITORY_LC }}:${{ github.ref_name }} hack/update-manifest.sh

- name: Release the kraken
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM docker.io/library/golang:1.19 as builder
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -13,8 +13,10 @@ RUN go mod download
COPY main.go main.go
COPY pkg/ pkg/

ARG TARGETARCH

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -a -o manager main.go

FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /
Expand Down
21 changes: 20 additions & 1 deletion hack/install-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

destination=$1
version=$(grep "^go " go.mod |awk '{print $2}')
tarball=go$version.linux-amd64.tar.gz

arch="$(uname -m)"

case $arch in
x86_64 | amd64)
arch="amd64"
;;
aarch64 | arm64)
arch="arm64"
;;
s390x)
arch="s390x"
;;
*)
echo "ERROR: invalid arch=${arch}, only support x86_64, aarch64 and s390x"
exit 1
;;
esac

tarball=go$version.linux-$arch.tar.gz
url=https://dl.google.com/go/

mkdir -p $destination
Expand Down

0 comments on commit c2d9ba6

Please sign in to comment.