From 0ef356706abb87f5acdf227b626fa57c4881a554 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 26 Nov 2024 11:56:09 +0000 Subject: [PATCH] Optimize build with XX Signed-off-by: Stefan Prodan --- .github/workflows/release.yml | 2 +- Dockerfile | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 612a1b8fc..b049a2097 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,7 +125,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') with: version: latest - args: release --release-notes=notes.md --clean --skip-validate + args: release --release-notes=notes.md --clean --skip=validate env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Generate SLSA metadata diff --git a/Dockerfile b/Dockerfile index 2fd8760e6..52044ed50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,11 @@ -FROM golang:1.23-alpine as builder +ARG GO_VERSION=1.23 +ARG XX_VERSION=1.4.0 + +FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx +FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine as builder + +# copy build utilities +COPY --from=xx / / ARG TARGETPLATFORM ARG REVISON @@ -17,7 +24,8 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # build -RUN CGO_ENABLED=0 go build \ +ENV CGO_ENABLED=0 +RUN xx-go build \ -ldflags "-s -w -X github.com/fluxcd/flagger/pkg/version.REVISION=${REVISON}" \ -a -o flagger ./cmd/flagger