-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
29 lines (21 loc) · 952 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FROM --platform=$BUILDPLATFORM golang:1.20 as builder
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG BUILD_DATE
COPY . /src
WORKDIR /src
RUN env GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go mod download && \
export GIT_COMMIT=$(git rev-parse HEAD) && \
export GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true) && \
env GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
go build -o k8s-mutate-image-and-policy-webhook \
-ldflags "-X github.com/sqooba/go-common/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} \
-X github.com/sqooba/go-common/version.BuildDate=${BUILD_DATE} \
-X github.com/sqooba/go-common/version.Version=${VERSION}" \
.
FROM --platform=$BUILDPLATFORM gcr.io/distroless/base
COPY --from=builder /src/k8s-mutate-image-and-policy-webhook /k8s-mutate-image-and-policy-webhook
USER nobody
ENTRYPOINT ["/k8s-mutate-image-and-policy-webhook"]
EXPOSE 8443