forked from infobloxopen/grafana-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (44 loc) · 1.43 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
ARG BUILDER_IMAGE=golang:1.18
ARG UBI_MINIMAL_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:9.1.0
ARG UBI_MICRO_IMAGE=registry.access.redhat.com/ubi9/ubi-micro:9.1.0
# Build the manager binary
# hadolint ignore=DL3006
FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} as builder
ARG TARGETARCH
ARG TARGETOS
ARG GOPROXY
ARG GOPRIVATE
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod ./
COPY go.sum ./
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
go mod download
# Copy the go source
COPY main.go ./main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/
COPY version/ version/
# Build
RUN GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
go build -a -o manager main.go
# hadolint ignore=DL3006
FROM --platform=${TARGETPLATFORM} ${UBI_MINIMAL_IMAGE} as ubi-minimal
# hadolint ignore=DL3006
FROM --platform=${TARGETPLATFORM} ${UBI_MICRO_IMAGE}
# copy Root CA bundle from ubi-minimal
COPY --from=ubi-minimal /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt
WORKDIR /
COPY --from=builder /workspace/manager .
RUN mkdir -p /opt/jsonnet && chown nobody /opt/jsonnet
USER nobody
COPY grafonnet-lib/grafonnet/ /opt/jsonnet/grafonnet
ENTRYPOINT ["./manager"]