forked from fluxcd/kustomize-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (30 loc) · 976 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ARG GO_VERSION=1.20
ARG XX_VERSION=1.2.1
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine as builder
# Copy the build utilities.
COPY --from=xx / /
ARG TARGETPLATFORM
WORKDIR /workspace
# copy api submodule
COPY api/ api/
# copy modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache modules
RUN go mod download
# copy source code
COPY main.go main.go
COPY controllers/ controllers/
COPY internal/ internal/
# build
ENV CGO_ENABLED=0
RUN xx-go build -trimpath -a -o kustomize-controller main.go
FROM alpine:3.17
# Uses GnuPG from edge to patch CVE-2022-3515.
RUN apk add --no-cache ca-certificates tini git openssh-client && \
apk add --no-cache gnupg --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main
COPY --from=builder /workspace/kustomize-controller /usr/local/bin/
USER 65534:65534
ENV GNUPGHOME=/tmp
ENTRYPOINT [ "/sbin/tini", "--", "kustomize-controller" ]