-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
175 lines (136 loc) · 8.25 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
############# builder #############
FROM golang:1.23.3 AS builder
WORKDIR /go/src/github.com/gardener/logging
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY pkg ./pkg
ARG TARGETOS
ARG TARGETARCH
ARG LD_FLAGS
RUN --mount=type=cache,target="/root/.cache/go-build" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build -buildmode=c-shared \
-o build/out_vali.so \
-ldflags="$LD_FLAGS" \
./cmd/fluent-bit-vali-plugin
RUN --mount=type=cache,target="/root/.cache/go-build" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go install \
-ldflags "$LD_FLAGS" \
./cmd/copy
RUN --mount=type=cache,target="/root/.cache/go-build" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go install \
-ldflags "$LD_FLAGS" \
./cmd/vali-curator
RUN --mount=type=cache,target="/root/.cache/go-build" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go install \
-ldflags "$LD_FLAGS" \
./cmd/event-logger
############# distroless-static
FROM gcr.io/distroless/static-debian12:nonroot AS distroless-static
############# fluent-bit-plugin #############
FROM distroless-static AS fluent-bit-plugin
COPY --from=builder /go/src/github.com/gardener/logging/build /source/plugins
COPY --from=builder /go/bin/copy /bin/cp
WORKDIR /
CMD ["/bin/cp", "/source/plugins/.", "/plugins"]
############# fluent-bit-vali #############
FROM ghcr.io/fluent/fluent-operator/fluent-bit:3.1.8 AS fluent-bit-vali
COPY --from=builder /go/src/github.com/gardener/logging/build /fluent-bit/plugins
WORKDIR /
CMD ["-e", "/fluent-bit/plugins/out_vali.so", "-c", "/fluent-bit/config/fluent-bit.conf"]
############# curator #############
FROM distroless-static AS curator
COPY --from=builder /go/bin/vali-curator /curator
WORKDIR /
EXPOSE 2718
ENTRYPOINT [ "/curator" ]
############# eventlogger #############
FROM distroless-static AS event-logger
COPY --from=builder /go/bin/event-logger /event-logger
WORKDIR /
ENTRYPOINT [ "/event-logger" ]
############# telegraf-builder #############
FROM golang:1.23.3 AS telegraf-builder
RUN git clone --depth 1 --branch v1.26.0 https://github.com/influxdata/telegraf.git
WORKDIR /go/telegraf
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=cache,target="/root/.cache/go-build" CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
############# iptables-builder #############
FROM alpine:3.20.3 AS iptables-builder
RUN apk add --update bash sudo iptables ncurses-libs libmnl && \
rm -rf /var/cache/apk/*
WORKDIR /volume
RUN mkdir -p ./bin ./sbin ./lib ./usr/bin ./usr/sbin ./usr/lib ./usr/lib/xtables ./usr/lib/bash ./tmp ./run ./etc/bash ./etc/openvpn ./usr/lib/openvpn/plugins ./etc/iproute2 ./etc/terminfo ./etc/logrotate.d ./etc/network/if-up.d ./usr/share/udhcpc ./etc/ssl/misc ./usr/lib/engines-1.1 ./run ./usr/lib/sudo \
&& cp -d /lib/ld-musl-* ./lib && echo "package musl" \
&& cp -d /lib/libc.musl-* ./lib && echo "package musl" \
&& cp -d -r /etc/terminfo/* ./etc/terminfo && echo "package ncurses-terminfo-base" \
&& cp -d /usr/lib/libformw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libmenuw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libncursesw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libpanelw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libreadline.so.* ./usr/lib && echo "package readline" \
&& cp -d /etc/inputrc ./etc && echo "package readline" \
&& cp -d /bin/bash ./bin && echo "package bash" \
&& cp -d /etc/bash/bashrc ./etc/bash && echo "package bash" \
&& cp -d /usr/lib/bash/* ./usr/lib/bash && echo "package bash" \
&& cp -d /lib/libz.* ./lib && echo "package zlib" \
&& cp -d /usr/lib/libmnl.* ./usr/lib && echo "package libmnl" \
&& cp -d /usr/lib/libnftnl* ./usr/lib && echo "package libnftnl" \
&& cp -d /etc/ethertypes ./etc && echo "package iptables" \
&& cp -d /sbin/iptables* ./sbin && echo "package iptables" \
&& cp -d /sbin/xtables* ./sbin && echo "package iptables" \
&& cp -d /usr/lib/libxtables* ./usr/lib && echo "package iptables" \
&& cp -d /usr/lib/xtables/* ./usr/lib/xtables && echo "package iptables" \
&& cp -d /usr/lib/sudo/* ./usr/lib/sudo && echo "package sudo" \
&& cp -d /etc/sudoers ./etc && echo "package sudo" \
&& cp -d /etc/passwd ./etc && echo "package sudo" \
&& cp -d /usr/bin/sudo ./usr/sbin && echo "package sudo" \
&& touch ./run/xtables.lock && echo "create /run/xtables.lock"
############# telegraf #############
FROM scratch AS telegraf
COPY --from=iptables-builder /volume /
COPY --from=telegraf-builder /go/telegraf/telegraf /usr/bin/telegraf
CMD [ "/usr/bin/telegraf"]
############# tune2fs-builder #############
FROM alpine:3.20.3 AS tune2fs-builder
RUN apk add --update bash e2fsprogs-extra mount gawk ncurses-libs && \
rm -rf /var/cache/apk/*
WORKDIR /volume
RUN mkdir -p ./lib ./usr/bin/ ./bin ./etc/bash ./usr/lib/bash ./usr/sbin/ ./etc/terminfo \
&& cp -d /usr/bin/gawk ./usr/bin && echo "package gawk" \
&& cp -d /lib/ld-musl-* ./lib && echo "package musl" \
&& cp -d /lib/libc.musl-* ./lib && echo "package musl" \
&& cp -d /lib/libmount.so.* ./lib && echo "package mount" \
&& cp -d /lib/libblkid.so.* ./lib && echo "package mount" \
&& cp -d /bin/mount ./bin && echo "package mount" \
&& cp -d -r /etc/terminfo/* ./etc/terminfo && echo "package ncurses-terminfo-base" \
&& cp -d /usr/lib/libformw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libmenuw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libncursesw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libpanelw.so.* ./usr/lib && echo "package ncurses-libs" \
&& cp -d /usr/lib/libreadline.so.* ./usr/lib && echo "package readline" \
&& cp -d /etc/inputrc ./etc && echo "package readline" \
&& cp -d /bin/bash ./bin && echo "package bash" \
&& cp -d /etc/bash/bashrc ./etc/bash && echo "package bash" \
&& cp -d /usr/lib/bash/* ./usr/lib/bash && echo "package bash" \
&& cp -d /lib/libext2fs.so.* ./lib && echo "package e2fsprogs-extra" \
&& cp -d /lib/libcom_err.so.* ./lib && echo "package e2fsprogs-extra" \
&& cp -d /lib/libuuid.so.* ./lib && echo "package e2fsprogs-extra" \
&& cp -d /lib/libe2p.so.* ./lib && echo "package e2fsprogs-extra" \
&& cp -d /usr/sbin/tune2fs ./usr/sbin && echo "package e2fsprogs-extra"
############# tune2fs #############
FROM scratch AS tune2fs
COPY --from=tune2fs-builder /volume /
CMD [ "/usr/sbin/tune2fs"]