From d9394c2dc9ed523cc9cba42530a4f3b8656a5501 Mon Sep 17 00:00:00 2001 From: Inbaraj S Date: Wed, 31 Jan 2024 16:46:10 +0530 Subject: [PATCH] Multi arch support (#39) --- .github/workflows/release.yaml | 29 ++++++++++++++++++----------- Dockerfile | 4 ++-- Makefile | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a66bb27c..ea88d689 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,21 +20,28 @@ jobs: IMAGE_REGISTRY: ghcr.io/oracle steps: - name: Checkout - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 with: - platforms: amd64 + platforms: linux/amd64,linux/arm64 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - - name: Log into GitHub Container Registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${GITHUB_ACTOR,,} --password-stdin - - - name: Build Image - run: REGISTRY="${{ env.IMAGE_REGISTRY }}" VERSION="${{ github.ref_name }}" make image + - name: Login to Docker + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Push Image - run: REGISTRY="${{ env.IMAGE_REGISTRY }}" VERSION="${{ github.ref_name }}" make push \ No newline at end of file + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + provenance: false + tags: ghcr.io/oracle/oci-native-ingress-controller:${{ github.ref_name }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index defb7a95..c1c7e2fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY . ./ # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. #RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod vendor -a -o dist/onic ./main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -mod vendor -a -o dist/onic ./main.go # For Open source FROM oraclelinux:7-slim @@ -34,4 +34,4 @@ COPY THIRD_PARTY_LICENSES.txt . # Copy the manager binary COPY --from=builder /workspace/dist/onic . -ENTRYPOINT ["/usr/local/bin/oci-native-ingress-controller/onic"] +ENTRYPOINT ["/usr/local/bin/oci-native-ingress-controller/onic"] \ No newline at end of file diff --git a/Makefile b/Makefile index a702e6e1..fcad8fdd 100644 --- a/Makefile +++ b/Makefile @@ -59,10 +59,10 @@ version: # Currently only supports amd build: ./main.go - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod vendor -a -o dist/onic ./main.go + CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GO111MODULE=on go build -mod vendor -a -o dist/onic ./main.go image: - docker build -t ${IMAGE_PATH} -f Dockerfile . + docker build --build-arg goos=$(GOOS) --build-arg goarch=$(GOARCH) -t ${IMAGE_PATH} -f Dockerfile . push: docker push ${IMAGE_PATH}