forked from Dynatrace/dynatrace-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
77 lines (63 loc) · 3.19 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
# setup build image
FROM golang:1.20.5@sha256:4b1fc02d16fca272e5e6e6adc98396219b43ef663a377eef4a97e881d364393f AS go-base
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y libbtrfs-dev libdevmapper-dev
# download go dependencies
FROM go-base AS go-mod
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# build operator binary
FROM go-mod AS operator-build
ARG GO_LINKER_ARGS
ARG GO_BUILD_TAGS
COPY src ./src
RUN CGO_ENABLED=1 CGO_CFLAGS="-O2 -Wno-return-local-addr" \
go build -tags "${GO_BUILD_TAGS}" -trimpath -ldflags="${GO_LINKER_ARGS}" \
-o ./build/_output/bin/dynatrace-operator ./src/cmd/
FROM registry.access.redhat.com/ubi9-micro:9.1.0@sha256:9fc815c51e62b33e4ff3225242ca2236ca4d6fcc3474e3b7e3004fea8924f8fd AS base
FROM registry.access.redhat.com/ubi9:9.1.0@sha256:49124e4acd09c98927882760476d617a85f155cb45759aea56b2ab020563c4b8 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.*
FROM 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.8.0@sha256:f6717ce72a2615c7fbc746b4068f788e78579c54c43b8716e5ce650d97af2df1 /csi-node-driver-registrar /usr/local/bin
COPY --from=registry.k8s.io/sig-storage/livenessprobe:v2.10.0@sha256:4dc0b87ccd69f9865b89234d8555d3a614ab0a16ed94a3016ffd27f8106132ce /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}