Skip to content

Commit

Permalink
fix multi-arch build
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Bugwadia <[email protected]>
  • Loading branch information
JimBugwadia committed Jan 23, 2024
1 parent ef4ad23 commit c51b2b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ARG BUILD_PLATFORM="linux/amd64"
ARG BUILDER_IMAGE="golang:1.20.6-alpine3.18"
ARG BUILDER_IMAGE="golang:1.21.6-alpine3.18"

FROM --platform=$BUILD_PLATFORM $BUILDER_IMAGE as builder
FROM --platform=$BUILDPLATFORM $BUILDER_IMAGE as builder

WORKDIR /
COPY . ./
Expand All @@ -15,7 +14,9 @@ RUN apk update && \
unzip -o ${SIGNER_BINARY_FILE}

# Build Go binary
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o kyverno-notation-aws .
ENV GOOS $TARGETOS
ENV GOARCH $TARGETARCH
RUN go build -ldflags="-w -s" -o kyverno-notation-aws .

FROM gcr.io/distroless/static:nonroot
WORKDIR /
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ build:

docker-build:
@echo Build kyverno-notation-aws image with docker... >&2
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 LD_FLAGS=$(LD_FLAGS) go build -o kyverno-notation-aws .
docker buildx build --platform linux/amd64,linux/arm64/v8 -t $(REPO_IMAGE):$(IMAGE_TAG_LATEST) --load .
docker buildx build --platform linux/amd64,linux/arm64/v8 -t $(REPO_IMAGE):$(IMAGE_TAG_LATEST) --push .

docker-publish:
@echo Build kyverno-notation-aws image with docker... >&2
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 LD_FLAGS=$(LD_FLAGS) go build -o kyverno-notation-aws .
docker buildx build --platform linux/amd64,linux/arm64/v8 -t $(REPO_IMAGE):$(IMAGE_TAG_LATEST) --load .
docker buildx build --platform linux/amd64,linux/arm64/v8 -t $(REPO_IMAGE):$(IMAGE_TAG_LATEST) --push .
docker tag $(REPO_IMAGE):$(IMAGE_TAG_LATEST) $(REPO_IMAGE):$(IMAGE_TAG_SHA)
docker push $(REPO_IMAGE):$(IMAGE_TAG_SHA)
docker push $(REPO_IMAGE):$(IMAGE_TAG_LATEST)
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/nirmata/kyverno-notation-aws

go 1.19
go 1.21

toolchain go1.21.1

require (
github.com/aws/aws-sdk-go-v2/config v1.26.5
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTg
github.com/go-logr/logr v0.3.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
Expand Down

0 comments on commit c51b2b5

Please sign in to comment.