diff --git a/.github/workflows/image-push.yaml b/.github/workflows/image-push.yaml index b2da99e6..82776b83 100644 --- a/.github/workflows/image-push.yaml +++ b/.github/workflows/image-push.yaml @@ -7,9 +7,10 @@ on: - 'v*.*.*' env: image-push-owner: 'k8snetworkplumbingwg' + BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/s390x jobs: - push-amd64: - name: Image push/amd64 + push-image: + name: Image push runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory @@ -36,8 +37,9 @@ jobs: with: context: . push: true - tags: ghcr.io/${{ github.repository }}:latest-amd64 + tags: ghcr.io/${{ github.repository }}:latest file: images/Dockerfile + platforms: ${{ env.BUILD_PLATFORMS }} build-args: | git_sha=${{ env.git_commit_hash }} @@ -49,6 +51,7 @@ jobs: push: true tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }} file: images/Dockerfile + platforms: ${{ env.BUILD_PLATFORMS }} build-args: | git_sha=${{ env.git_commit_hash }} diff --git a/images/Dockerfile b/images/Dockerfile index 7bf1fc3a..8aaeea9c 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -1,11 +1,16 @@ -FROM quay.io/projectquay/golang:1.22 as builder +FROM --platform=$BUILDPLATFORM quay.io/projectquay/golang:1.22 AS builder ENV GOPATH=/go +ARG TARGETOS +ARG TARGETARCH +ENV TARGETOS=${TARGETOS:-linux} +ENV TARGETARCH=${TARGETARCH:-amd64} + RUN mkdir -p $GOPATH/src/github.com/maiqueb/multus-dynamic-networks-controller WORKDIR $GOPATH/src/github.com/maiqueb/multus-dynamic-networks-controller COPY . . -RUN GOOS=linux CGO_ENABLED=0 go build -o /dynamic-networks-controller ./cmd/dynamic-networks-controller +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -o /dynamic-networks-controller ./cmd/dynamic-networks-controller -FROM registry.access.redhat.com/ubi8/ubi-minimal +FROM --platform=linux/${TARGETARCH} registry.access.redhat.com/ubi8/ubi-minimal COPY --from=builder /dynamic-networks-controller /dynamic-networks-controller ARG git_url=https://github.com/k8snetworkplumbingwg/multus-dynamic-networks-controller.git