-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (28 loc) · 807 Bytes
/
Dockerfile
File metadata and controls
33 lines (28 loc) · 807 Bytes
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
# Builder stage
ARG BUILDER_IMAGE
ARG INTERMEDIATE_IMAGE
FROM $BUILDER_IMAGE AS builder
ENV GO111MODULE=on
WORKDIR /
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY version/ version/
ARG ARCH
ARG CGO
ARG BUILDPARAM
RUN CGO_ENABLED=${CGO} GOOS=linux GOARCH=${ARCH} go build ${GOBUILDFLAGS} -o /staticroute-operator main.go
# Intermediate stage to apply capabilities
FROM $INTERMEDIATE_IMAGE AS intermediate
COPY --from=builder /staticroute-operator /staticroute-operator
RUN setcap cap_net_admin+ep /staticroute-operator
RUN chmod go+x /staticroute-operator
# Final image
FROM scratch
COPY --from=intermediate /staticroute-operator /staticroute-operator
USER 2000:2000
ENTRYPOINT ["/staticroute-operator"]