-
Notifications
You must be signed in to change notification settings - Fork 57
/
Dockerfile
305 lines (270 loc) · 11.7 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
RUN apk add curl git
ARG BUILDARCH TARGETARCH
ENV BUILDARCH=$BUILDARCH \
CGO_ENABLED=0 \
GOARCH=$TARGETARCH \
TARGETARCH=$TARGETARCH
COPY helper-* /bin/
# https://github.com/argoproj/argo-cd/releases/latest
FROM builder AS argocd
RUN helper-curl bin argocd \
https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-@GOARCH
# https://github.com/warpstreamlabs/bento/releases
FROM builder AS bento
ARG BENTO_VERSION=1.3.0
RUN helper-curl tar bento \
https://github.com/warpstreamlabs/bento/releases/download/v${BENTO_VERSION}/bento_${BENTO_VERSION}[email protected]
# https://github.com/docker/compose/releases
FROM builder AS compose
ARG COMPOSE_VERSION=2.17.2
RUN helper-curl bin docker-compose \
https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-linux-@UARCH
# https://github.com/google/go-containerregistry/tree/main/cmd/crane
FROM builder AS crane
RUN go install github.com/google/go-containerregistry/cmd/crane@latest
RUN cp $(find bin -name crane) /usr/local/bin
# https://github.com/fluxcd/flux2/releases
FROM builder AS flux
ARG FLUX_VERSION=2.3.0
RUN helper-curl tar flux \
https://github.com/fluxcd/flux2/releases/download/v$FLUX_VERSION/flux_${FLUX_VERSION}[email protected]
# https://github.com/helm/helm/releases
FROM builder AS helm
ARG HELM_VERSION=3.11.2
RUN helper-curl tar "--strip-components=1 linux-@GOARCH/helm" \
https://get.helm.sh/helm-v${HELM_VERSION}[email protected]
# Use emulation instead of cross-compilation for that one.
# (The source is small enough, so I don't know if cross-compilation
# would be worth the effort.)
FROM alpine AS httping
RUN apk add build-base cmake gettext git musl-libintl ncurses-dev openssl-dev
RUN git clone https://github.com/folkertvanheusden/httping
WORKDIR httping
RUN sed -i s/60/0/ utils.c
RUN cmake .
RUN make install BINDIR=/usr/local/bin
# https://github.com/simeji/jid/releases
FROM builder AS jid
ARG JID_VERSION=0.7.6
RUN go install github.com/simeji/jid/cmd/jid@v$JID_VERSION
RUN cp $(find bin -name jid) /usr/local/bin
# https://github.com/derailed/k9s/releases
FROM builder AS k9s
RUN helper-curl tar k9s \
https://github.com/derailed/k9s/releases/latest/download/[email protected]
# https://github.com/kubernetes/kompose/releases
FROM builder AS kompose
RUN helper-curl bin kompose \
https://github.com/kubernetes/kompose/releases/latest/download/kompose-linux-@GOARCH
# https://github.com/kubecolor/kubecolor/releases
FROM builder AS kubecolor
ARG KUBECOLOR_VERSION=0.3.2
RUN helper-curl tar kubecolor \
https://github.com/kubecolor/kubecolor/releases/download/v${KUBECOLOR_VERSION}/kubecolor_${KUBECOLOR_VERSION}[email protected]
# https://github.com/kubernetes/kubernetes/releases
FROM builder AS kubectl
ARG KUBECTL_VERSION=1.30.2
RUN helper-curl bin kubectl \
https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/@GOARCH/kubectl
# https://github.com/stackrox/kube-linter/releases
FROM builder AS kube-linter
ARG KUBELINTER_VERSION=v0.6.8
RUN go install golang.stackrox.io/kube-linter/cmd/kube-linter@$KUBELINTER_VERSION
RUN cp $(find bin -name kube-linter) /usr/local/bin
# https://github.com/doitintl/kube-no-trouble/releases
FROM builder AS kubent
ARG KUBENT_VERSION=0.7.2
RUN helper-curl tar kubent \
https://github.com/doitintl/kube-no-trouble/releases/download/${KUBENT_VERSION}/kubent-${KUBENT_VERSION}[email protected]
# https://github.com/bitnami-labs/sealed-secrets/releases
FROM builder AS kubeseal
ARG KUBESEAL_VERSION=0.27.0
RUN helper-curl tar kubeseal \
https://github.com/bitnami-labs/sealed-secrets/releases/download/v$KUBESEAL_VERSION/[email protected]
# https://github.com/kubernetes-sigs/kustomize/releases
FROM builder AS kustomize
ARG KUSTOMIZE_VERSION=5.4.2
RUN helper-curl tar kustomize \
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v$KUSTOMIZE_VERSION/kustomize_v${KUSTOMIZE_VERSION}[email protected]
# https://ngrok.com/download
FROM builder AS ngrok
RUN helper-curl tar ngrok \
https://bin.equinox.io/c/4VmDzA7iaHb/[email protected]
# https://github.com/derailed/popeye/releases
FROM builder AS popeye
RUN helper-curl tar popeye \
https://github.com/derailed/popeye/releases/latest/download/[email protected]
# https://github.com/regclient/regclient/releases
FROM builder AS regctl
ARG REGCLIENT_VERSION=0.6.1
RUN helper-curl bin regctl \
https://github.com/regclient/regclient/releases/download/v$REGCLIENT_VERSION/regctl-linux-@GOARCH
# This tool is still used in the kustomize section, but we will probably
# deprecate it eventually as we only use a tiny feature that doesn't seem
# to be available anymore in more recent versions (or requires some work
# to adapt). Also, it's not available on all platforms and doesn't compile.
FROM builder AS ship
ARG SHIP_VERSION=0.51.3
RUN helper-curl tar ship \
https://github.com/replicatedhq/ship/releases/download/v${SHIP_VERSION}/ship_${SHIP_VERSION}[email protected]
# https://github.com/GoogleContainerTools/skaffold/releases
FROM builder AS skaffold
RUN helper-curl bin skaffold \
https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-@GOARCH
# https://github.com/stern/stern/releases
FROM builder AS stern
ARG STERN_VERSION=1.30.0
RUN helper-curl tar stern \
https://github.com/stern/stern/releases/download/v${STERN_VERSION}/stern_${STERN_VERSION}[email protected]
# https://github.com/tilt-dev/tilt/releases
FROM builder AS tilt
ARG TILT_VERSION=0.33.17
RUN helper-curl tar tilt \
https://github.com/tilt-dev/tilt/releases/download/v${TILT_VERSION}/tilt.${TILT_VERSION}[email protected]
# https://github.com/vmware-tanzu/velero/releases
FROM builder AS velero
ARG VELERO_VERSION=1.14.0
RUN helper-curl tar "--strip-components=1 velero-v${VELERO_VERSION}-linux-@GOARCH/velero" \
https://github.com/vmware-tanzu/velero/releases/download/v${VELERO_VERSION}/velero-v${VELERO_VERSION}[email protected]
# https://github.com/carvel-dev/ytt/releases
FROM builder AS ytt
ARG YTT_VERSION=0.49.1
RUN helper-curl bin ytt \
https://github.com/carvel-dev/ytt/releases/download/v${YTT_VERSION}/ytt-linux-@GOARCH
# https://github.com/carvel-dev/kapp/releases
FROM builder AS kapp
ARG YTT_VERSION=0.62.1
RUN helper-curl bin kapp \
https://github.com/carvel-dev/kapp/releases/download/v${YTT_VERSION}/kapp-linux-@GOARCH
FROM alpine AS shpod
ENV COMPLETIONS=/usr/share/bash-completion/completions
RUN apk add --no-cache apache2-utils bash bash-completion curl docker-cli file fzf gettext git iputils jq libintl ncurses openssh openssl screen sudo tmux tree unzip vim yq
COPY --from=argocd /usr/local/bin/argocd /usr/local/bin
COPY --from=bento /usr/local/bin/bento /usr/local/bin
COPY --from=compose /usr/local/bin/docker-compose /usr/local/bin
COPY --from=crane /usr/local/bin/crane /usr/local/bin
COPY --from=flux /usr/local/bin/flux /usr/local/bin
COPY --from=helm /usr/local/bin/helm /usr/local/bin
COPY --from=httping /usr/local/bin/httping /usr/local/bin
COPY --from=jid /usr/local/bin/jid /usr/local/bin
COPY --from=k9s /usr/local/bin/k9s /usr/local/bin
COPY --from=kapp /usr/local/bin/kapp /usr/local/bin
COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin
COPY --from=kubecolor /usr/local/bin/kubecolor /usr/local/bin
COPY --from=kube-linter /usr/local/bin/kube-linter /usr/local/bin
COPY --from=kubent /usr/local/bin/kubent /usr/local/bin
COPY --from=kubeseal /usr/local/bin/kubeseal /usr/local/bin
COPY --from=kustomize /usr/local/bin/kustomize /usr/local/bin
COPY --from=ngrok /usr/local/bin/ngrok /usr/local/bin
COPY --from=popeye /usr/local/bin/popeye /usr/local/bin
COPY --from=regctl /usr/local/bin/regctl /usr/local/bin
COPY --from=ship /usr/local/bin/ship /usr/local/bin
COPY --from=skaffold /usr/local/bin/skaffold /usr/local/bin
COPY --from=stern /usr/local/bin/stern /usr/local/bin
COPY --from=tilt /usr/local/bin/tilt /usr/local/bin
COPY --from=velero /usr/local/bin/velero /usr/local/bin
COPY --from=ytt /usr/local/bin/ytt /usr/local/bin
RUN set -e ; for BIN in \
argocd \
crane \
flux \
helm \
kapp \
kubectl \
kube-linter \
kustomize \
regctl \
skaffold \
tilt \
velero \
ytt \
; do echo $BIN ; $BIN completion bash > $COMPLETIONS/$BIN.bash ; done ;\
stern --completion bash > $COMPLETIONS/stern
RUN cd /tmp \
&& git clone https://github.com/ahmetb/kubectx \
&& cd kubectx \
&& mv kubectx /usr/local/bin/kctx \
&& mv kubens /usr/local/bin/kns \
&& mv completion/kubectx.bash $COMPLETIONS/kctx.bash \
&& mv completion/kubens.bash $COMPLETIONS/kns.bash \
&& cd .. \
&& rm -rf kubectx
RUN cd /tmp \
&& git clone https://github.com/jonmosco/kube-ps1 \
&& cp kube-ps1/kube-ps1.sh /etc/profile.d/ \
&& rm -rf kube-ps1
# Create user and finalize setup.
RUN echo k8s:x:1000: >> /etc/group \
&& echo k8s:x:1000:1000::/home/k8s:/bin/bash >> /etc/passwd \
&& echo "k8s ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/k8s \
&& mkdir /home/k8s \
&& chown -R k8s:k8s /home/k8s/ \
&& sed -i 's/#MaxAuthTries 6/MaxAuthTries 42/' /etc/ssh/sshd_config
ARG TARGETARCH
RUN \
if [ "$TARGETARCH" != "386" ]; then \
mkdir /tmp/krew \
&& cd /tmp/krew \
&& curl -fsSL https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_$TARGETARCH.tar.gz | tar -zxf- \
&& sudo -u k8s -H ./krew-linux_$TARGETARCH install krew \
&& cd \
&& rm -rf /tmp/krew \
; fi
COPY --chown=1000:1000 bash_profile /home/k8s/.bash_profile
COPY --chown=1000:1000 vimrc /home/k8s/.vimrc
COPY --chown=1000:1000 tmux.conf /home/k8s/.tmux.conf
COPY motd /etc/motd
COPY setup-tailhist.sh /usr/local/bin
# Generate a list of all installed versions.
RUN ( \
ab -V | head -n1 ;\
argocd version --client | head -n1 ;\
echo "bento $(bento --version | head -n1)" ;\
bash --version | head -n1 ;\
curl --version | head -n1 ;\
docker version --format="Docker {{.Client.Version}}" ;\
envsubst --version | head -n1 ;\
flux --version ;\
git --version ;\
jq --version ;\
ssh -V ;\
tmux -V ;\
yq --version ;\
docker-compose version ;\
echo "crane $(crane version)" ;\
echo "Helm $(helm version --short)" ;\
httping --version ;\
jid --version ;\
echo "k9s $(k9s version | grep Version)" ;\
kapp --version | head -n1 ;\
echo "kubecolor $(kubecolor --kubecolor-version)" ;\
echo "kubectl $(kubectl version --client | head -n1)" ;\
echo "kube-linter $(kube-linter version)" ;\
echo "kubent $(kubent --version 2>&1)" ;\
kubeseal --version ;\
echo "kustomize $(kustomize version | head -n1)" ;\
ngrok version ;\
echo "popeye $(popeye version | grep Version)" ;\
echo "regctl $(regctl version --format={{.VCSTag}})" ;\
echo "ship $(ship version | jq .version)" ;\
echo "skaffold $(skaffold version)" ;\
echo "stern $(stern --version | grep ^version)" ;\
echo "tilt $(tilt version)" ;\
echo "velero $(velero version --client-only | grep Version)" ;\
) > versions.txt
# If there is a tty, give us a shell.
# (This happens e.g. when we do "docker run -ti jpetazzo/shpod".)
# Otherwise, start an SSH server.
# (This happens e.g. when we use that image in a Pod in a Deployment.)
CMD \
if tty >/dev/null; then \
exec login -f k8s && \
: ; \
else \
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" && \
echo k8s:${PASSWORD-k8s} | chpasswd && \
exec /usr/sbin/sshd -D -e && \
: ; \
fi
EXPOSE 22/tcp