-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
299 lines (264 loc) · 8.55 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
######################################################### TOOLCHAIN VERSIONING #########################################
ARG UBUNTU_VERSION="22.04"
ARG DOCKER_VERSION="24.0.7"
ARG KUBECTL_VERSION="1.28.2"
ARG OC_CLI_VERSION="4.14.1"
# Using Helm 3.10.1 as the latest Helm version has a null value override issue.
# For additional details, refer to: https://github.com/helm/helm/issues/5184
ARG HELM_VERSION="3.10.1"
ARG TERRAFORM_VERSION="1.6.4"
ARG ANSIBLE_CORE_VERSION="2.15.6"
ARG ANSIBLE_VERSION="8.6.1"
ARG ANSIBLE_LINT="6.22.0"
ARG JINJA_VERSION="3.1.2"
ARG CRICTL_VERSION="1.28.0"
ARG VELERO_VERSION="1.12.1"
ARG ZSH_VERSION="5.8.1"
ARG VAULT_VERSION="1.15.2"
######################################################### BINARY-DOWNLOADER ############################################
FROM alpine as binary_downloader
ARG TARGETARCH
ARG DOCKER_VERSION
ARG KUBECTL_VERSION
ARG OC_CLI_VERSION
ARG HELM_VERSION
ARG TERRAFORM_VERSION
ARG ANSIBLE_VERSION
ARG ANSIBLE_CORE_VERSION
ARG ANSIBLE_LINT
ARG JINJA_VERSION
ARG CRICTL_VERSION
ARG VELERO_VERSION
ARG STERN_VERSION
ARG ZSH_VERSION
ARG VAULT_VERSION
USER root
WORKDIR /root/download
RUN apk --update add \
curl \
openssl \
unzip \
tar \
wget
WORKDIR /root/download
RUN mkdir -p /root/download/binaries
#download oc-cli
RUN if [[ ! -z ${OC_CLI_VERSION} ]] ; then \
mkdir -p oc_cli && \
curl -SsL --retry 5 -o oc_cli.tar.gz https://mirror.openshift.com/pub/openshift-v4/$TARGETARCH/clients/ocp/$OC_CLI_VERSION/openshift-client-linux-$OC_CLI_VERSION.tar.gz && \
tar xvf oc_cli.tar.gz -C oc_cli && \
mv "/root/download/oc_cli/oc" "/root/download/binaries/oc"; \
fi
#download helm3-cli
RUN if [[ ! -z ${HELM_VERSION} ]] ; then \
mkdir helm && curl -SsL --retry 5 "https://get.helm.sh/helm-v$HELM_VERSION-linux-$TARGETARCH.tar.gz" | tar xz -C ./helm && \
mv "/root/download/helm/linux-${TARGETARCH}/helm" "/root/download/binaries/helm"; \
fi
#download terraform
RUN if [[ ! -z ${TERRAFORM_VERSION} ]] ; then \
wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform\_${TERRAFORM_VERSION}\_linux_${TARGETARCH}.zip && \
unzip ./terraform\_${TERRAFORM_VERSION}\_linux_${TARGETARCH}.zip -d terraform_cli && \
mv "/root/download/terraform_cli/terraform" "/root/download/binaries/terraform"; \
fi
#download docker
#credits to https://github.com/docker-library/docker/blob/463595652d2367887b1ffe95ec30caa00179be72/18.09/Dockerfile
#need to stick to uname since docker download link uses "aarch64" instead of "arm64"
RUN if [[ ! -z ${DOCKER_VERSION} ]] ; then \
mkdir -p /root/download/docker/bin && \
set -eux && \
arch="$(uname -m)" && \
wget -q -O docker.tgz "https://download.docker.com/linux/static/stable/${arch}/docker-${DOCKER_VERSION}.tgz" && \
tar --extract \
--file docker.tgz \
--strip-components 1 \
--directory /root/download/docker/bin && \
mv /root/download/docker/bin/* -t "/root/download/binaries/" ; \
fi
#download kubectl
RUN if [[ ! -z ${KUBECTL_VERSION} ]] ; then \
wget -q https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/${TARGETARCH}/kubectl -O /root/download/kubectl && \
mv "/root/download/kubectl" "/root/download/binaries/kubectl"; \
fi
#download crictl
RUN if [[ ! -z ${CRICTL_VERSION} ]] ; then \
mkdir -p /root/download/crictl && \
wget -q "https://github.com/kubernetes-sigs/cri-tools/releases/download/v$CRICTL_VERSION/crictl-v$CRICTL_VERSION-linux-${TARGETARCH}.tar.gz" -O /root/download/crictl.tar.gz && \
tar zxvf /root/download/crictl.tar.gz -C /root/download/crictl && \
mv "/root/download/crictl/crictl" "/root/download/binaries/crictl"; \
fi
#download yq
RUN curl -Lo yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${TARGETARCH} && \
mv "/root/download/yq" "/root/download/binaries/yq"
#download tcpping
#todo: switch to https://github.com/deajan/tcpping/blob/master/tcpping when ubuntu is supported
RUN wget -q https://raw.githubusercontent.com/deajan/tcpping/original-1.8/tcpping -O /root/download/tcpping && \
mv "/root/download/tcpping" "/root/download/binaries/tcpping"
#download velero CLI
RUN if [[ ! -z ${VELERO_VERSION} ]] ; then \
wget -q https://github.com/vmware-tanzu/velero/releases/download/v${VELERO_VERSION}/velero-v${VELERO_VERSION}-linux-${TARGETARCH}.tar.gz && \
tar -xvf velero-v${VELERO_VERSION}-linux-${TARGETARCH}.tar.gz && \
mv velero-v${VELERO_VERSION}-linux-${TARGETARCH}/velero /root/download/binaries/velero; \
fi
#download vault CLI
RUN if [[ ! -z ${VAULT_VERSION} ]] ; then \
wget -q https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_${TARGETARCH}.zip && \
unzip ./vault_${VAULT_VERSION}_linux_${TARGETARCH}.zip -d vault_cli && \
mv "/root/download/vault_cli/vault" "/root/download/binaries/vault"; \
fi
######################################################### BASE-IMAGE ###################################################
FROM ubuntu:$UBUNTU_VERSION as base-image
ARG TARGETARCH
ARG DOCKER_VERSION
ARG KUBECTL_VERSION
ARG OC_CLI_VERSION
ARG HELM_VERSION
ARG TERRAFORM_VERSION
ARG ANSIBLE_VERSION
ARG ANSIBLE_CORE_VERSION
ARG ANSIBLE_LINT
ARG JINJA_VERSION
ARG CRICTL_VERSION
ARG VELERO_VERSION
ARG ZSH_VERSION
ARG VAULT_VERSION
#use bash during docker build
SHELL ["/bin/bash", "-c"]
#env
ENV DEBIAN_FRONTEND noninteractive
USER root
WORKDIR /root
#https://github.com/waleedka/modern-deep-learning-docker/issues/4#issue-292539892
#bc and tcptraceroute needed for tcping
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get upgrade -y && \
apt-get install -y \
apt-utils \
apt-transport-https \
bash-completion \
bc \
build-essential \
ca-certificates \
curl \
dnsutils \
fping \
git \
gnupg \
gnupg2 \
groff \
iputils-ping \
jq \
less \
libssl-dev \
locales \
lsb-release \
nano \
net-tools \
netcat \
nmap \
openssl \
python3 \
python3-dev \
python3-pip \
software-properties-common \
sudo \
telnet \
tcptraceroute \
traceroute \
unzip \
uuid-runtime \
vim \
wget \
zip \
zlib1g-dev &&\
apt-get clean -y && \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/archives/*
#install zsh + configure git
RUN locale-gen en_US.UTF-8
RUN apt-get update && \
apt-get install -y \
fonts-powerline \
powerline \
zsh
RUN git config --global --add safe.directory '*'
#install common requirements
RUN pip3 install \
cryptography \
hvac \
jmespath \
openshift \
pyyaml \
kubernetes \
netaddr \
passlib \
pbr \
pip \
pyOpenSSL \
pyvmomi \
setuptools
#install ansible
RUN if [[ ! -z ${ANSIBLE_VERSION} && ! -z ${JINJA_VERSION} ]] ; then \
pip3 install \
ansible-core==${ANSIBLE_CORE_VERSION} \
ansible==${ANSIBLE_VERSION} \
ansible-lint==${ANSIBLE_LINT} \
jinja2==${JINJA_VERSION}; \
fi
#install ansible collection
RUN ansible-galaxy collection install kubernetes.core
ENV TERM xterm
ENV ZSH_THEME agnoster
RUN wget -q https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
######################################################### IMAGE ########################################################
FROM base-image
ARG TARGETARCH
ARG DOCKER_VERSION
ARG KUBECTL_VERSION
ARG OC_CLI_VERSION
ARG HELM_VERSION
ARG TERRAFORM_VERSION
ARG ANSIBLE_VERSION
ARG ANSIBLE_CORE_VERSION
ARG ANSIBLE_LINT
ARG JINJA_VERSION
ARG CRICTL_VERSION
ARG VELERO_VERSION
ARG ZSH_VERSION
ARG VAULT_VERSION
#use bash during docker build
SHELL ["/bin/bash", "-c"]
#env
ENV EDITOR nano
#copy binaries
COPY --from=binary_downloader "/root/download/binaries/*" "/usr/local/bin/"
RUN chmod -R +x /usr/local/bin && \
docker --version && \
yq --version && \
tcpping; \
if [[ ! -z "HELM_VERSION" ]] ; then \
helm version && \
helm repo update; \
fi; \
if [[ ! -z "KUBECTL_VERSION" ]] ; then \
kubectl version --client=true; \
fi; \
if [[ ! -z "CRICTL_VERSION" ]] ; then \
crictl --version; \
fi; \
if [[ ! -z "OC_CLI_VERSION" ]] ; then \
oc version --client; \
fi; \
if [[ ! -z "TERRAFORM_VERSION" ]] ; then \
terraform version ; \
fi; \
if [[ ! -z "VELERO_VERSION" ]] ; then \
velero version --client-only; \
fi
COPY .bashrc /root/.bashrc
COPY .zshrc /root/.zshrc
USER root
WORKDIR /root/project
CMD ["/bin/bash"]