Skip to content

Commit

Permalink
Support Arm64 (#2)
Browse files Browse the repository at this point in the history
* Support Arm64
  • Loading branch information
fjogeleit committed Jun 27, 2021
1 parent 726179c commit d31b37b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
FROM golang:1.16-buster as builder

ARG LD_FLAGS
ARG TARGETPLATFORM

WORKDIR /app
COPY . .

RUN go get -d -v \
&& go install -v

RUN make build
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)

FROM alpine:latest
LABEL MAINTAINER "Frank Jogeleit <frank.jogeleit@gweb.de>"
RUN go env

WORKDIR /app
RUN CGO_ENABLED=0 go build -ldflags="${LD_FLAGS}" -o /app/build/kyverno-plugin -v

RUN apk add --update --no-cache ca-certificates
FROM scratch
LABEL MAINTAINER "Frank Jogeleit <frank.jogeleit@gweb.de>"

RUN addgroup -S kyverno-plugin && adduser -u 1234 -S kyverno-plugin -G kyverno-plugin
WORKDIR /app

USER 1234

Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
GO ?= go

BUILD ?= build
REPO ?= fjogeleit/policy-reporter-kyverno-plugin
IMAGE_TAG ?= 0.3.0
LD_FLAGS="-s -w"

all: build

Expand All @@ -23,3 +25,12 @@ coverage:
.PHONY: build
build: prepare
CGO_ENABLED=0 $(GO) build -v -ldflags="-s -w" $(GOFLAGS) -o $(BUILD)/kyverno-plugin .

.PHONY: docker-build
docker-build:
@docker buildx build --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS)

.PHONY: docker-push
docker-push:
@docker buildx build --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) --push
@docker buildx build --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO):latest . --build-arg LD_FLAGS=$(LD_FLAGS) --push

0 comments on commit d31b37b

Please sign in to comment.