From 145d0a370d2a89ba8a4bf5416aca64649409590d Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Fri, 18 Oct 2024 18:04:06 +0530 Subject: [PATCH] fix: arm64 build targets The previous commit did not enable arm64 build correctly. Signed-off-by: Noel Georgi --- .kres.yaml | 10 ++++++++++ Dockerfile | 16 ++++++++++++++-- Makefile | 11 +++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.kres.yaml b/.kres.yaml index d3736fb..53c4ee3 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -5,6 +5,16 @@ spec: extraEnvironment: PLATFORM: linux/amd64,linux/arm64 --- +kind: golang.Build +spec: + outputs: + linux-amd64: + GOOS: linux + GOARCH: amd64 + linux-arm64: + GOOS: linux + GOARCH: arm64 +--- kind: common.Repository spec: conformLicenseCheck: false diff --git a/Dockerfile b/Dockerfile index 34acfb0..7a770d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-10-10T13:37:23Z by kres 34e72ac. +# Generated on 2024-10-18T12:33:47Z by kres 34e72ac. ARG TOOLCHAIN @@ -79,7 +79,15 @@ COPY --from=generate / / WORKDIR /src/cmd/release-tool ARG GO_BUILDFLAGS ARG GO_LDFLAGS -RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /release-tool-linux-amd64 +RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /release-tool-linux-amd64 + +# builds release-tool-linux-arm64 +FROM base AS release-tool-linux-arm64-build +COPY --from=generate / / +WORKDIR /src/cmd/release-tool +ARG GO_BUILDFLAGS +ARG GO_LDFLAGS +RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /release-tool-linux-arm64 # runs unit-tests with race detector FROM base AS unit-tests-race @@ -96,6 +104,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g FROM scratch AS release-tool-linux-amd64 COPY --from=release-tool-linux-amd64-build /release-tool-linux-amd64 /release-tool-linux-amd64 +FROM scratch AS release-tool-linux-arm64 +COPY --from=release-tool-linux-arm64-build /release-tool-linux-arm64 /release-tool-linux-arm64 + FROM scratch AS unit-tests COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt @@ -103,6 +114,7 @@ FROM release-tool-linux-${TARGETARCH} AS release-tool FROM scratch AS release-tool-all COPY --from=release-tool-linux-amd64 / / +COPY --from=release-tool-linux-arm64 / / FROM base-image-release-tool AS image-release-tool RUN apk add --no-cache git git-lfs make sed diff --git a/Makefile b/Makefile index 0913046..de55879 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-10-10T13:37:23Z by kres 34e72ac. +# Generated on 2024-10-18T12:33:47Z by kres 34e72ac. # common variables @@ -182,8 +182,15 @@ $(ARTIFACTS)/release-tool-linux-amd64: .PHONY: release-tool-linux-amd64 release-tool-linux-amd64: $(ARTIFACTS)/release-tool-linux-amd64 ## Builds executable for release-tool-linux-amd64. +.PHONY: $(ARTIFACTS)/release-tool-linux-arm64 +$(ARTIFACTS)/release-tool-linux-arm64: + @$(MAKE) local-release-tool-linux-arm64 DEST=$(ARTIFACTS) + +.PHONY: release-tool-linux-arm64 +release-tool-linux-arm64: $(ARTIFACTS)/release-tool-linux-arm64 ## Builds executable for release-tool-linux-arm64. + .PHONY: release-tool -release-tool: release-tool-linux-amd64 ## Builds executables for release-tool. +release-tool: release-tool-linux-amd64 release-tool-linux-arm64 ## Builds executables for release-tool. .PHONY: lint-markdown lint-markdown: ## Runs markdownlint.