-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
37 lines (28 loc) · 883 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
# Build the operator binary using the Docker's Debian image.
FROM --platform=${BUILDPLATFORM} golang:1.23 AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /workspace
# Copy the Go Modules manifests.
COPY go.mod go.mod
COPY go.sum go.sum
# Cache the Go Modules
RUN go mod download
# Copy the Go sources.
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/
# Build the operator binary.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o flux-operator cmd/main.go
# Run the operator binary using Google's Distroless image.
FROM gcr.io/distroless/static:nonroot
WORKDIR /
# Copy the license.
COPY LICENSE /licenses/LICENSE
# Copy the manifests data.
COPY config/data/ /data/
# Copy the operator binary.
COPY --from=builder /workspace/flux-operator .
# Run the operator as a non-root user.
USER 65532:65532
ENTRYPOINT ["/flux-operator"]