From dc406614dceb8439774c0834a89099fa3dadc816 Mon Sep 17 00:00:00 2001 From: Sirish Bathina Date: Mon, 2 Dec 2024 14:25:19 -1000 Subject: [PATCH] Multi-platform kubestr image (#316) * multi-platform kubestr image * Adjusting Dockerfile to do a native compile + emulated image build * remove explicit TARGETPLATFORM --- .github/workflows/docker-publish.yml | 1 + Dockerfile | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 261318e..874654b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -61,6 +61,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 with: + platforms: linux/amd64,linux/arm64,linux/ppc64le context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index da4344c..9cffecf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ -FROM golang:1.22-bullseye AS builder +ARG BUILDPLATFROM + +FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS builder + +ARG TARGETOS +ARG TARGETARCH +ARG TARGETPLATFROM ENV GO111MODULE=on \ CGO_ENABLED=0 \ - GOOS=linux \ - GOARCH=amd64 \ - GOBIN=/dist + GOOS=${TARGETOS} \ + GOARCH=${TARGETARCH} WORKDIR /app @@ -15,7 +20,7 @@ RUN go mod download COPY . . -RUN go install -ldflags="-w -s" . +RUN go build -o /dist/kubestr -ldflags="-w -s" . FROM alpine:3.19