Skip to content

Commit

Permalink
feat: add support for arm64 builds
Browse files Browse the repository at this point in the history
Resolves #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>
  • Loading branch information
twelho authored and frezbo committed Jan 22, 2024
1 parent 952dc54 commit 6af92b5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .conform.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions .kres.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -107,13 +115,17 @@ 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

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
Expand Down
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6af92b5

Please sign in to comment.