forked from jpetazzo/shpod
-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
292 lines (259 loc) · 11.2 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
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/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/latest
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/latest
FROM builder AS helm
ARG HELM_VERSION=3.16.0
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
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/latest
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/latest
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/latest
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/latest
FROM builder AS kubecolor
ARG KUBECOLOR_VERSION=0.4.0
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/latest
FROM builder AS kubectl
ARG KUBECTL_VERSION=1.31.0
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/latest
FROM builder AS kube-linter
ARG KUBELINTER_VERSION=0.6.8
RUN go install golang.stackrox.io/kube-linter/cmd/kube-linter@v${KUBELINTER_VERSION}
RUN cp $(find bin -name kube-linter) /usr/local/bin
# https://github.com/doitintl/kube-no-trouble/releases/latest
FROM builder AS kubent
ARG KUBENT_VERSION=0.7.3
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/latest
FROM builder AS kubeseal
ARG KUBESEAL_VERSION=0.27.1
RUN helper-curl tar kubeseal \
https://github.com/bitnami-labs/sealed-secrets/releases/download/v${KUBESEAL_VERSION}/kubeseal-${KUBESEAL_VERSION}[email protected]
# https://github.com/kubernetes-sigs/kustomize/releases/latest
FROM builder AS kustomize
ARG KUSTOMIZE_VERSION=5.4.3
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/latest
FROM builder AS regctl
ARG REGCLIENT_VERSION=0.7.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.
# https://github.com/replicatedhq/ship/releases/latest
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/latest
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/latest
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/latest
FROM builder AS tilt
ARG TILT_VERSION=0.33.20
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/latest
FROM builder AS velero
ARG VELERO_VERSION=1.14.1
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/latest
FROM builder AS ytt
ARG YTT_VERSION=0.63.3
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/latest
FROM builder AS kapp
ARG YTT_VERSION=0.63.3
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 docker-compose file gettext git iputils jq libintl ncurses openssh openssl screen sudo tmux tree vim yq
COPY --from=argocd /usr/local/bin/argocd /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 \
docker \
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 ;\
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 --short --client)" ;\
echo "kube-linter $(kube-linter version)" ;\
echo "kubent $(kubent --version 2>&1)" ;\
kubeseal --version ;\
kustomize version --short ;\
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 bretfisher/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