forked from mreferre/eksutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
327 lines (263 loc) · 11.3 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
ARG FROM_IMAGE=amazonlinux
#ARG FROM_TAG=2022.0.20220531.0
ARG FROM_TAG=2
# create a small image for runtime.
FROM golang:1.18-buster as builder
RUN mkdir -p /go/src/github.com/eksutils
WORKDIR /go/src/github.com/eksutils
COPY . /go/src/github.com/eksutils
RUN pwd && ls -la && go mod init
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
################## BUILD OK ################################
#FROM ${FROM_IMAGE}:${FROM_TAG}
#FROM amazonlinux:2022.0.20220531.0
FROM amazonlinux:2
COPY --from=builder /go/src/github.com/eksutils/main /main
################ UTILITIES VERSIONS ########################
ARG USER_NAME="eksutils"
ARG KUBE_RELEASE_VER=v1.22.11
ARG NVM_VERSION=0.39.1
ARG NODE_VERSION=14
#ARG IAM_AUTH_VER=0.4.0
ARG EKSUSER_VER=0.2.1
#ARG KUBECFG_VER=0.16.0
ARG KSONNET_VER=0.13.1
ARG K9S_VER=0.25.21
ARG DOCKER_COMPOSE_VER=2.6.1
ARG KIND_VER=0.14.0
ARG OCTANT_VER=0.25.1
ARG AWSCLI_URL_BASE=awscli.amazonaws.com
ARG AWSCLI_URL_FILE=awscli-exe-linux-x86_64.zip
ARG KUBECTX_VER=0.9.4
ARG KUBENS_VER=0.9.4
ARG BAT_VER=0.21.0
ARG VSCODESERVER_VER=4.5.0
ARG AWS_CDK_VERSION=2.30.0
ARG FLUXCTL_VERSION=1.25.2
################## SETUP ENV ###############################
ENV USER_NAME $USER_NAME
ENV USER_PASSWORD $USER_PASSWORD
ENV CONTAINER_IMAGE_VER=v1.1.2
### OCTANT
# browser autostart at octant launch is disabled
# ip address and port are modified (to better work with Cloud9)
ENV OCTANT_DISABLE_OPEN_BROWSER=1
ENV OCTANT_LISTENER_ADDR="0.0.0.0:8080"
### NODE
ENV NVM_DIR=/usr/local/nvm
ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
ENV NODE_VERSION=${NODE_VERSION}
### CODE-SERVER
ENV PATH=/usr/local/bin/code-server/bin:$PATH
################## BEGIN INSTALLATION ######################
## This adds the script that checks the version of the tools and utilities installed
ADD utilsversions.sh .
## This will remove intermediate downloads between RUN steps as /tmp is out of the container FS
VOLUME /tmp
WORKDIR /tmp
######################################
## begin setup add-on systems tools ##
######################################
# setup various utils (latest at time of docker build)
# docker is being installed to support DinD scenarios (e.g. for being able to build)
# httpd-tools include the ab tool (for benchmarking http end points)
RUN yum update -y \
#&& yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
&& yum install -y \
git \
sudo \
httpd-tools \
iputils \
jq \
less \
openssl \
python3 \
tar \
unzip \
vi \
wget \
which \
wget \
fonts-powerline \
emacs-nox \
telnet \
net-tools \
nc \
iftop \
tshark \
tmux \
bind-utils \
procps-ng \
figlet \
iproute \
libcap-ng-utils \
the_silver_searcher \
&& mkdir -p ${NVM_DIR} \
#&& curl -s https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default \
&& node --version \
#&& curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo \
# && yum install -y yarn \
&& yum clean all \
&& rm -rf /var/cache/yum
##### Make python3 default
#RUN ln -sf /usr/bin/python3 /usr/bin/python
#sudo ln -sf /usr/bin/python2.7 /usr/bin/python
# Fix Yum after python3 installation
#RUN sed -i 's$#!/usr/bin/python$#!/usr/bin/python2.7$' /usr/bin/yum \
# && sed -i 's$#! /usr/bin/python$#!/usr/bin/python2$' /usr/libexec/urlgrabber-ext-down
####################################
## end setup add-on systems tools ##
####################################
########################################
## begin setup runtime pre-requisites ##
########################################
RUN . $NVM_DIR/nvm.sh \
#&& amazon-linux-extras install epel -y \
#&& yum install -y libuv
&& npm install -g npm \
&& npm install -g ts-node \
&& npm install -g typescript \
&& npm install yarn -g \
# setup the aws cdk cli (latest at time of docker build)
&& npm i -g aws-cdk \
# setup the aws cdk (latest at time of docker build)
&& npm i -g aws-cdk-lib \
# setup the cdk8s cli (latest at time of docker build)
&& npm i -g cdk8s-cli
RUN echo OK
# setup pip (latest at time of docker build)
RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& PYTHON=python3 python3 get-pip.py \
&& pip install --upgrade aws-cdk-lib \
awscli \
awslogs
########################################
### end setup runtime pre-requisites ###
########################################
###########################
## begin setup utilities ##
###########################
# setup zsh (shell)
RUN sh -c "$(wget -O- https://raw.githubusercontent.com/deluan/zsh-in-docker/master/zsh-in-docker.sh)"
# setup the aws cli v2 (latest at time of docker build)
RUN curl -Ls "https://${AWSCLI_URL_BASE}/${AWSCLI_URL_FILE}" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& /usr/local/bin/aws --version
# setup the eb cli (latest at time of docker build)
RUN pip install awsebcli --upgrade
# setup kubectl (latest at time of docker build)
RUN curl -sLO https://storage.googleapis.com/kubernetes-release/release/${KUBE_RELEASE_VER}/bin/linux/amd64/kubectl \
&& chmod +x ./kubectl \
&& mv ./kubectl /usr/local/bin/kubectl
# setup the IAM authenticator for aws (for Amazon EKS)
# RUN curl -sLo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${IAM_AUTH_VER}/aws-iam-authenticator_${IAM_AUTH_VER}_linux_amd64 \
# && chmod +x ./aws-iam-authenticator \
# && mv ./aws-iam-authenticator /usr/local/bin
# setup Helm (latest at time of docker build)
RUN curl -sLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 \
&& chmod +x get_helm.sh \
&& ./get_helm.sh
# setup eksctl (latest at time of docker build)
RUN curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp \
&& mv -v /tmp/eksctl /usr/local/bin
# setup the eksuser tool
RUN curl -sLo eksuser-linux-amd64.zip https://github.com/prabhatsharma/eksuser/releases/download/v${EKSUSER_VER}/eksuser-linux-amd64.zip \
&& unzip eksuser-linux-amd64.zip \
&& chmod +x ./binaries/linux/eksuser \
&& mv ./binaries/linux/eksuser /usr/local/bin/eksuser
# setup kubecfg
# RUN curl -sLo kubecfg https://github.com/ksonnet/kubecfg/releases/download/v${KUBECFG_VER}/kubecfg-linux-amd64 \
# && chmod +x kubecfg \
# && mv kubecfg /usr/local/bin/kubecfg
# setup kubectx
RUN curl -sLo kubectx.tar.gz https://github.com/ahmetb/kubectx/releases/download/v${KUBECTX_VER}/kubectx_v${KUBECTX_VER}_linux_x86_64.tar.gz \
&& tar -xvf kubectx.tar.gz \
&& chmod +x kubectx \
&& mv kubectx /usr/local/bin/kubectx
# setup kubens
RUN curl -sLo kubens.tar.gz https://github.com/ahmetb/kubectx/releases/download/v${KUBENS_VER}/kubens_v${KUBENS_VER}_linux_x86_64.tar.gz \
&& tar -xvf kubens.tar.gz \
&& chmod +x kubens \
&& mv kubens /usr/local/bin/kubens
# setup ksonnet
RUN curl -sLo - https://github.com/ksonnet/ksonnet/releases/download/v${KSONNET_VER}/ks_${KSONNET_VER}_linux_amd64.tar.gz |tar xfz - --strip-components=1 \
&& mv ks /usr/bin/ks
# setup k9s
RUN curl -sLo - https://github.com/derailed/k9s/releases/download/v${K9S_VER}/k9s_Linux_x86_64.tar.gz |tar xfz - \
&& mv k9s /usr/local/bin/k9s
# setup docker
RUN PYTHON=python2 amazon-linux-extras install docker -y
# setup docker-compose
RUN curl -sL "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VER}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
# setup kind
RUN curl -Lo ./kind https://kind.sigs.k8s.io/dl/v${KIND_VER}/kind-linux-amd64 \
&& chmod +x ./kind \
&& mv ./kind /usr/local/bin/kind
# setup Octant
RUN curl -sLo - https://github.com/vmware-tanzu/octant/releases/download/v${OCTANT_VER}/octant_${OCTANT_VER}_Linux-64bit.tar.gz |tar xfz - --strip-components=1 \
&& mv octant /usr/local/bin/octant
# setup glooctl
RUN curl -sL https://run.solo.io/gloo/install | sh \
&& mv $HOME/.gloo/bin/glooctl /usr/local/bin \
&& rm -r $HOME/.gloo
# Traceback (most recent call last):
# File "<string>", line 1, in <module>
# File "<string>", line 1, in <listcomp>
# TypeError: string indices must be integers
# setup bat
RUN curl -sSL https://github.com/sharkdp/bat/releases/download/v${BAT_VER}/bat-v${BAT_VER}-x86_64-unknown-linux-gnu.tar.gz | tar xfz - \
&& mv ./bat-v${BAT_VER}-x86_64-unknown-linux-gnu/bat /usr/local/bin
# setup VS Code server
RUN curl -sSL https://github.com/cdr/code-server/releases/download/v${VSCODESERVER_VER}/code-server-${VSCODESERVER_VER}-linux-amd64.tar.gz | tar xfz - \
&& mv code-server-${VSCODESERVER_VER}-linux-amd64 /usr/local/bin/code-server
# terminal colors with xterm
ENV TERM xterm
# set the zsh theme
ENV ZSH_THEME agnoster
# install oh-my-zsh
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
RUN curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/download/v2.0.1/ec2-instance-selector-`uname | tr '[:upper:]' '[:lower:]'`-amd64 && chmod +x ec2-instance-selector \
&& mv ec2-instance-selector /usr/local/bin
#RUN cd ~/.oh-my-zsh/custom/themes && git clone https://github.com/bhilburn/powerlevel9k.git
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
RUN git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf \
&& yes | ~/.fzf/install
RUN curl -Lo fluxctl https://github.com/fluxcd/flux/releases/download/${FLUXCTL_VERSION}/fluxctl_linux_amd64 \
&& chmod 755 fluxctl \
&& mv fluxctl /usr/local/bin
RUN cd ~/.oh-my-zsh/custom/plugins/ \
&& git clone https://github.com/zsh-users/zsh-autosuggestions \
&& git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
#install vegeta http injector
RUN cd /tmp; wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz \
&& tar zxvf vegeta_12.8.4_linux_amd64.tar.gz && mv vegeta /usr/local/bin/
#########################
## end setup utilities ##
#########################
##################### INSTALLATION END #####################
RUN useradd -ms /bin/bash $USER_NAME
RUN cp -r ~/.oh-my-zsh /home/$USER_NAME/ \
&& chown -R $USER_NAME:$USER_NAME /home/$USER_NAME \
# Enable scrolling in zsh in cloud9
&& sed -i -e "s/echoti smkx/#echoti smkx/" ~/.oh-my-zsh/lib/key-bindings.zsh
# the user we're applying this too (otherwise it most likely install for root)
WORKDIR /home/$USER_NAME
COPY .zshrc /root/.zshrc
COPY .zshrc /home/$USER_NAME/.zshrc
COPY .p10k.zsh /root/.p10k.zsh
COPY .p10k.zsh /home/$USER_NAME/.p10k.zsh
############################################################
########### Tools and Utilities versions checks ############
############################################################
#RUN /utilsversions.sh
USER $USER_NAME
EXPOSE 8080
CMD ["/main"]