-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathDockerfile
86 lines (68 loc) · 3.66 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# check=skip=RedundantTargetPlatform
# setup build image
FROM --platform=$BUILDPLATFORM golang:1.23.5@sha256:51a6466e8dbf3e00e422eb0f7a97ac450b2d57b33617bbe8d2ee0bddcd9d0d37 AS operator-build
WORKDIR /app
ARG DEBUG_TOOLS
RUN if [ "$DEBUG_TOOLS" = "true" ]; then \
GOBIN=/app/build/_output/bin go install github.com/go-delve/delve/cmd/dlv@latest; \
fi
COPY go.mod go.sum ./
RUN go mod download -x
COPY pkg ./pkg
COPY cmd ./cmd
ARG GO_LINKER_ARGS
ARG GO_BUILD_TAGS
ARG TARGETARCH
ARG TARGETOS
RUN --mount=type=cache,target="/root/.cache/go-build" \
--mount=type=cache,target="/go/pkg" \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -tags "${GO_BUILD_TAGS}" -trimpath -ldflags="${GO_LINKER_ARGS}" \
-o ./build/_output/bin/dynatrace-operator ./cmd/
# platform is required, otherwise the copy command will copy the wrong architecture files, don't trust GitHub Actions linting warnings
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9-micro:9.5-1736426761@sha256:f6e0a71b7e0875b54ea559c2e0a6478703268a8d4b8bdcf5d911d0dae76aef51 AS base
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9:9.5-1736404036@sha256:53d6c19d664f4f418ce5c823d3a33dbb562a2550ea249cf07ef10aa063ace38f AS dependency
RUN mkdir -p /tmp/rootfs-dependency
COPY --from=base / /tmp/rootfs-dependency
RUN dnf install --installroot /tmp/rootfs-dependency \
util-linux-core tar \
--releasever 9 \
--setopt install_weak_deps=false \
--nodocs -y \
&& dnf --installroot /tmp/rootfs-dependency clean all \
&& rm -rf \
/tmp/rootfs-dependency/var/cache/* \
/tmp/rootfs-dependency/var/log/dnf* \
/tmp/rootfs-dependency/var/log/yum.*
# platform is required, otherwise the copy command will copy the wrong architecture files, don't trust GitHub Actions linting warnings
FROM --platform=$TARGETPLATFORM base
COPY --from=dependency /tmp/rootfs-dependency /
# operator binary
COPY --from=operator-build /app/build/_output/bin /usr/local/bin
# csi binaries
COPY --from=registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.13.0@sha256:d7138bcc3aa5f267403d45ad4292c95397e421ea17a0035888850f424c7de25d /csi-node-driver-registrar /usr/local/bin
COPY --from=registry.k8s.io/sig-storage/livenessprobe:v2.15.0@sha256:2c5f9dc4ea5ac5509d93c664ae7982d4ecdec40ca7b0638c24e5b16243b8360f /livenessprobe /usr/local/bin
COPY ./third_party_licenses /usr/share/dynatrace-operator/third_party_licenses
COPY LICENSE /licenses/
# custom scripts
COPY hack/build/bin /usr/local/bin
LABEL name="Dynatrace Operator" \
vendor="Dynatrace LLC" \
maintainer="Dynatrace LLC" \
version="1.x" \
release="1" \
url="https://www.dynatrace.com" \
summary="The Dynatrace Operator is an open source Kubernetes Operator for easily deploying and managing Dynatrace components for Kubernetes / OpenShift observability. By leveraging the Dynatrace Operator you can innovate faster with the full potential of Kubernetes / OpenShift and Dynatrace’s best-in-class observability and intelligent automation." \
description="Automate Kubernetes observability with Dynatrace" \
io.k8s.description="Automate Kubernetes observability with Dynatrace" \
io.k8s.display-name="Dynatrace Operator" \
io.openshift.tags="observability,monitoring,dynatrace,operator,logging,metrics,tracing,prometheus,alerts" \
vcs-url="https://github.com/Dynatrace/dynatrace-operator.git" \
vcs-type="git" \
changelog-url="https://github.com/Dynatrace/dynatrace-operator/releases"
ENV OPERATOR=dynatrace-operator \
USER_UID=1001 \
USER_NAME=dynatrace-operator
RUN /usr/local/bin/user_setup
ENTRYPOINT ["/usr/local/bin/entrypoint"]
USER ${USER_UID}:${USER_UID}