feat: add support for arm64 builds

Resolves https://github.com/siderolabs/discovery-service/issues/52.
`make rekres` also updated some of the image tags.

Signed-off-by: Dennis Marttinen <twelho@welho.tech>
Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Dennis Marttinen
2024-01-21 12:30:28 +02:00
committed by Noel Georgi
parent 952dc5438f
commit 6af92b54d6
5 changed files with 62 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-08-25T16:11:00Z by kres d2252ce.
# Generated on 2024-01-22T17:51:41Z by kres latest.
---
policies:

View File

@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-01-12T12:34:10Z by kres latest.
# Generated on 2024-01-22T17:52:47Z by kres latest.
name: default
concurrency:
@ -80,12 +80,14 @@ jobs:
- name: push-discovery-service
if: github.event_name != 'pull_request'
env:
PLATFORM: linux/amd64,linux/arm64
PUSH: "true"
run: |
make image-discovery-service
- name: push-discovery-service-latest
if: github.event_name != 'pull_request'
env:
PLATFORM: linux/amd64,linux/arm64
PUSH: "true"
run: |
make image-discovery-service TAG=latest

View File

@ -1,4 +1,20 @@
---
kind: common.Image
name: image-discovery-service
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: service.CodeCov
spec:
targetThreshold: 30

View File

@ -2,7 +2,7 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-01-12T12:34:10Z by kres latest.
# Generated on 2024-01-22T17:51:41Z by kres latest.
ARG TOOLCHAIN
@ -14,9 +14,9 @@ FROM ghcr.io/siderolabs/ca-certificates:v1.6.0 AS image-ca-certificates
FROM ghcr.io/siderolabs/fhs:v1.6.0 AS image-fhs
# runs markdownlint
FROM docker.io/node:21.4.0-alpine3.18 AS lint-markdown
FROM docker.io/node:21.5.0-alpine3.19 AS lint-markdown
WORKDIR /src
RUN npm i -g markdownlint-cli@0.37.0
RUN npm i -g markdownlint-cli@0.38.0
RUN npm i sentences-per-line@0.2.1
COPY .markdownlint.json .
COPY ./README.md ./README.md
@ -70,7 +70,15 @@ COPY --from=generate / /
WORKDIR /src/cmd/discovery-service
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 /discovery-service-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 /discovery-service-linux-amd64
# builds discovery-service-linux-arm64
FROM base AS discovery-service-linux-arm64-build
COPY --from=generate / /
WORKDIR /src/cmd/discovery-service
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 /discovery-service-linux-arm64
# runs gofumpt
FROM base AS lint-gofumpt
@ -107,6 +115,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g
FROM scratch AS discovery-service-linux-amd64
COPY --from=discovery-service-linux-amd64-build /discovery-service-linux-amd64 /discovery-service-linux-amd64
FROM scratch AS discovery-service-linux-arm64
COPY --from=discovery-service-linux-arm64-build /discovery-service-linux-arm64 /discovery-service-linux-arm64
FROM scratch AS unit-tests
COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt
@ -114,6 +125,7 @@ FROM discovery-service-linux-${TARGETARCH} AS discovery-service
FROM scratch AS discovery-service-all
COPY --from=discovery-service-linux-amd64 / /
COPY --from=discovery-service-linux-arm64 / /
FROM scratch AS image-discovery-service
ARG TARGETARCH

View File

@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-01-12T14:05:03Z by kres 0e666ea-dirty.
# Generated on 2024-01-22T17:51:41Z by kres latest.
# common variables
@ -88,6 +88,23 @@ To create a builder instance, run:
docker buildx create --name local --use
If running builds that needs to be cached aggresively create a builder instance with the following:
docker buildx create --name local --use --config=config.toml
config.toml contents:
[worker.oci]
gc = true
gckeepstorage = 50000
[[worker.oci.gcpolicy]]
keepBytes = 10737418240
keepDuration = 604800
filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"]
[[worker.oci.gcpolicy]]
all = true
keepBytes = 53687091200
If you already have a compatible builder instance, you may use that instead.
@ -167,8 +184,15 @@ $(ARTIFACTS)/discovery-service-linux-amd64:
.PHONY: discovery-service-linux-amd64
discovery-service-linux-amd64: $(ARTIFACTS)/discovery-service-linux-amd64 ## Builds executable for discovery-service-linux-amd64.
.PHONY: $(ARTIFACTS)/discovery-service-linux-arm64
$(ARTIFACTS)/discovery-service-linux-arm64:
@$(MAKE) local-discovery-service-linux-arm64 DEST=$(ARTIFACTS)
.PHONY: discovery-service-linux-arm64
discovery-service-linux-arm64: $(ARTIFACTS)/discovery-service-linux-arm64 ## Builds executable for discovery-service-linux-arm64.
.PHONY: discovery-service
discovery-service: discovery-service-linux-amd64 ## Builds executables for discovery-service.
discovery-service: discovery-service-linux-amd64 discovery-service-linux-arm64 ## Builds executables for discovery-service.
.PHONY: lint-markdown
lint-markdown: ## Runs markdownlint.