Skip to content

Commit

Permalink
fix: multi arch build
Browse files Browse the repository at this point in the history
Builds and pushes for arm64

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Sep 5, 2022
1 parent 5613733 commit 42c0ffb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-08-31T21:37:24Z by kres ec2cd64.
# Generated on 2022-09-05T17:11:08Z by kres 871f67c.

kind: pipeline
type: kubernetes
Expand Down Expand Up @@ -169,6 +169,7 @@ steps:
from_secret: ghcr_token
GHCR_USERNAME:
from_secret: ghcr_username
PLATFORM: linux/amd64,linux/arm64
PUSH: true
volumes:
- name: outer-docker-socket
Expand Down
8 changes: 8 additions & 0 deletions .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: common.Image
name: image-bldr
spec:
pushLatest: false
droneExtraEnvironment:
PLATFORM: linux/amd64,linux/arm64
entrypointArgs:
- frontend
---
Expand All @@ -15,6 +17,12 @@ spec:
linux-arm64:
GOOS: linux
GOARCH: arm64
darwin-amd64:
GOOS: darwin
GOARCH: amd64
darwin-arm64:
GOOS: darwin
GOARCH: arm64
---
kind: auto.CustomSteps
spec:
Expand Down
36 changes: 30 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2022-08-31T21:36:31Z by kres ec2cd64.
# Generated on 2022-09-05T17:08:38Z by kres 871f67c.

ARG TOOLCHAIN

# cleaned up specs and compiled versions
FROM scratch AS generate

FROM ghcr.io/siderolabs/ca-certificates:v1.1.0 AS image-ca-certificates
FROM ghcr.io/siderolabs/ca-certificates:v1.2.0 AS image-ca-certificates

FROM ghcr.io/siderolabs/fhs:v1.1.0 AS image-fhs
FROM ghcr.io/siderolabs/fhs:v1.2.0 AS image-fhs

# runs markdownlint
FROM docker.io/node:18.7.0-alpine3.16 AS lint-markdown
FROM docker.io/node:18.8.0-alpine3.16 AS lint-markdown
WORKDIR /src
RUN npm i -g markdownlint-cli@0.31.1
RUN npm i -g markdownlint-cli@0.32.2
RUN npm i [email protected]
COPY .markdownlint.json .
COPY ./README.md ./README.md
Expand All @@ -27,7 +27,7 @@ FROM ${TOOLCHAIN} AS toolchain
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev

# build tools
FROM toolchain AS tools
FROM --platform=${BUILDPLATFORM} toolchain AS tools
ENV GO111MODULE on
ENV CGO_ENABLED 0
ENV GOPATH /go
Expand Down Expand Up @@ -55,6 +55,24 @@ COPY ./cmd ./cmd
COPY ./internal ./internal
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null

# builds bldr-darwin-amd64
FROM base AS bldr-darwin-amd64-build
COPY --from=generate / /
WORKDIR /src/cmd/bldr
ARG VERSION_PKG="github.com/siderolabs/bldr/internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=darwin go build -ldflags "-s -w -X ${VERSION_PKG}.Name=bldr -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /bldr-darwin-amd64

# builds bldr-darwin-arm64
FROM base AS bldr-darwin-arm64-build
COPY --from=generate / /
WORKDIR /src/cmd/bldr
ARG VERSION_PKG="github.com/siderolabs/bldr/internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=darwin go build -ldflags "-s -w -X ${VERSION_PKG}.Name=bldr -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /bldr-darwin-arm64

# builds bldr-linux-amd64
FROM base AS bldr-linux-amd64-build
COPY --from=generate / /
Expand Down Expand Up @@ -105,6 +123,12 @@ FROM base AS unit-tests-run
ARG TESTPKGS
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}

FROM scratch AS bldr-darwin-amd64
COPY --from=bldr-darwin-amd64-build /bldr-darwin-amd64 /bldr-darwin-amd64

FROM scratch AS bldr-darwin-arm64
COPY --from=bldr-darwin-arm64-build /bldr-darwin-arm64 /bldr-darwin-arm64

FROM scratch AS bldr-linux-amd64
COPY --from=bldr-linux-amd64-build /bldr-linux-amd64 /bldr-linux-amd64

Expand Down
20 changes: 17 additions & 3 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 2022-08-31T21:36:40Z by kres ec2cd64.
# Generated on 2022-09-05T17:08:38Z by kres 871f67c.

# common variables

Expand All @@ -17,7 +17,7 @@ GO_VERSION ?= 1.19
GOIMPORTS_VERSION ?= v0.1.12
PROTOBUF_GO_VERSION ?= 1.28.1
GRPC_GO_VERSION ?= 1.2.0
GRPC_GATEWAY_VERSION ?= 2.11.1
GRPC_GATEWAY_VERSION ?= 2.11.3
VTPROTOBUF_VERSION ?= 0.3.0
DEEPCOPY_VERSION ?= v0.5.5
TESTPKGS ?= ./...
Expand Down Expand Up @@ -133,6 +133,20 @@ unit-tests-race: ## Performs unit tests with race detection enabled.
coverage: ## Upload coverage data to codecov.io.
bash -c "bash <(curl -s https://codecov.io/bash) -f $(ARTIFACTS)/coverage.txt -X fix"

.PHONY: $(ARTIFACTS)/bldr-darwin-amd64
$(ARTIFACTS)/bldr-darwin-amd64:
@$(MAKE) local-bldr-darwin-amd64 DEST=$(ARTIFACTS)

.PHONY: bldr-darwin-amd64
bldr-darwin-amd64: $(ARTIFACTS)/bldr-darwin-amd64 ## Builds executable for bldr-darwin-amd64.

.PHONY: $(ARTIFACTS)/bldr-darwin-arm64
$(ARTIFACTS)/bldr-darwin-arm64:
@$(MAKE) local-bldr-darwin-arm64 DEST=$(ARTIFACTS)

.PHONY: bldr-darwin-arm64
bldr-darwin-arm64: $(ARTIFACTS)/bldr-darwin-arm64 ## Builds executable for bldr-darwin-arm64.

.PHONY: $(ARTIFACTS)/bldr-linux-amd64
$(ARTIFACTS)/bldr-linux-amd64:
@$(MAKE) local-bldr-linux-amd64 DEST=$(ARTIFACTS)
Expand All @@ -148,7 +162,7 @@ $(ARTIFACTS)/bldr-linux-arm64:
bldr-linux-arm64: $(ARTIFACTS)/bldr-linux-arm64 ## Builds executable for bldr-linux-arm64.

.PHONY: bldr
bldr: bldr-linux-amd64 bldr-linux-arm64 ## Builds executables for bldr.
bldr: bldr-darwin-amd64 bldr-darwin-arm64 bldr-linux-amd64 bldr-linux-arm64 ## Builds executables for bldr.

.PHONY: lint-markdown
lint-markdown: ## Runs markdownlint.
Expand Down
2 changes: 0 additions & 2 deletions hack/test/Dockerfile

This file was deleted.

0 comments on commit 42c0ffb

Please sign in to comment.