This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.go-alpine
197 lines (190 loc) · 7.57 KB
/
Dockerfile.go-alpine
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
ARG JX_VERSION=2.1.39
FROM gcr.io/jenkinsxio/jx:$JX_VERSION as jx
FROM lachlanevenson/k8s-kubectl:v1.13.12 as kubectl
FROM lachlanevenson/k8s-helm:v2.14.1 as helm
FROM google/cloud-sdk:289.0.0-alpine as gcloud
FROM groovy:3.0-jdk8-alpine as groovy
FROM golang:1.12.15-alpine3.10 as base
ARG user=developer
ARG group=wheel
ARG home=/home/${user}
ARG uid=1000
ARG SHELL
ARG SHELL_PACKAGES
ENV HUB_VERSION 2.11.2
ENV DEP_VERSION 0.5.1
ENV VELERO_VERSION 1.1.0
ENV SKAFFOLD_VERSION 1.0.1
ENV CONTAINER_STRUCTURE_TEST_VERSION 1.8.0
ENV GOPLS_VERSION v0.2
ENV GOPATH ${home}/go-workspace
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
ENV GROOVY_HOME /opt/groovy
ENV GH_CLI_VERSION 0.6.3
WORKDIR /
# Install standard dependencies
RUN apk --no-cache --update add \
$SHELL \
${SHELL}-doc \
$SHELL_PACKAGES \
ack \
bind-tools \
ca-certificates \
curl \
diffutils \
docker \
dos2unix \
findutils \
git \
git-email \
git-perl \
gnupg \
grep \
jq \
less \
less-doc \
libc-dev \
libc6-compat \
make \
man \
man-pages \
mdocml-apropos \
multitail \
ngrep \
nmap \
openjdk8 \
openssh-client \
openssl \
postgresql \
py-crcmod \
py-pip \
py-setuptools \
python \
python-dev \
shadow \
sudo \
tar \
terraform \
tig \
tmux \
tree \
unzip \
util-linux \
vault \
vim \
wget \
zip \
&& apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
# Setup dirs for groovy
&& mkdir -p /opt /etc/hub \
# Install hub-cli
&& curl -sL https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-linux-amd64-${HUB_VERSION}.tgz | tar zx --strip 2 -C /usr/local/bin hub-linux-amd64-${HUB_VERSION}/bin/hub \
&& curl -sL https://raw.githubusercontent.com/github/hub/v${HUB_VERSION}/etc/hub.${SHELL}_completion.sh > /etc/hub/.hub.${SHELL}_completion.sh \
# velero
&& curl -f -L https://github.com/heptio/velero/releases/download/v${VELERO_VERSION}/velero-v${VELERO_VERSION}-linux-amd64.tar.gz | tar xzv \
&& mv velero-v${VELERO_VERSION}-linux-amd64/velero /usr/local/bin/ \
&& rm -rf velero-v${VELERO_VERSION}-linux-amd64 \
&& curl -f -Lo skaffold https://storage.googleapis.com/skaffold/releases/v${SKAFFOLD_VERSION}/skaffold-linux-amd64 \
&& chmod +x skaffold \
&& mv skaffold /usr/local/bin \
&& curl -LO https://storage.googleapis.com/container-structure-test/v${CONTAINER_STRUCTURE_TEST_VERSION}/container-structure-test-linux-amd64 \
&& chmod +x container-structure-test-linux-amd64 \
&& mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test \
# GitHub CLI
&& curl -f -L https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_386.tar.gz| tar xzv \
&& mv gh_${GH_CLI_VERSION}_linux_386/bin/gh /usr/local/bin/ \
&& rm -rf gh_${GH_CLI_VERSION}_linux_386
COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=helm /usr/local/bin/helm /usr/local/bin/helm
COPY --from=gcloud /google-cloud-sdk /usr/local/google-cloud-sdk
COPY --from=groovy /opt/groovy /opt/groovy
# gcloud configurations
ENV PATH /usr/local/google-cloud-sdk/bin:$PATH
RUN ln -s /lib /lib64 \
&& gcloud config set core/disable_usage_reporting true \
&& gcloud config set component_manager/disable_update_check true \
&& gcloud config set metrics/environment github_docker_image \
&& gcloud components install alpha beta \
# groovy configurations
&& ln -s "${GROOVY_HOME}/bin/grape" /usr/bin/grape \
&& ln -s "${GROOVY_HOME}/bin/groovy" /usr/bin/groovy \
&& ln -s "${GROOVY_HOME}/bin/groovyc" /usr/bin/groovyc \
&& ln -s "${GROOVY_HOME}/bin/groovyConsole" /usr/bin/groovyConsole \
&& ln -s "${GROOVY_HOME}/bin/groovydoc" /usr/bin/groovydoc \
&& ln -s "${GROOVY_HOME}/bin/groovysh" /usr/bin/groovysh \
&& ln -s "${GROOVY_HOME}/bin/java2groovy" /usr/bin/java2groovy \
# Install pre-commit (https://pre-commit.com/) & detect-secrets (https://github.com/Yelp/detect-secrets)
&& pip install pre-commit \
detect-secrets \
yamale \
yamllint \
&& sed -i "s/root:\/bin\/ash/root:\/bin\/$SHELL/" /etc/passwd \
# Add developer user
&& mkdir -p ${home} \
&& adduser -h ${home} -u ${uid} -G ${group} -s /bin/${SHELL} -D ${user} \
&& echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& mkdir -p $GOPATH/src $GOPATH/bin \
# Setup Docker hack - there must be a better way
&& usermod -a -G docker ${user} \
&& usermod -a -G root ${user} \
# Add go packages
&& go get github.com/go-delve/delve/cmd/dlv \
&& go get github.com/gohugoio/hugo \
&& go get github.com/google/ko/cmd/ko \
&& go get github.com/jenkins-x/jx-release-version \
&& go get github.com/mfuentesg/ksd \
&& go get github.com/nsf/gocode \
&& go get github.com/starkandwayne/safe \
&& go get golang.org/x/tools/cmd/gorename \
&& go get gotest.tools/gotestsum \
&& $GOPATH/bin/gocode set propose-builtins true \
# Install dep
&& curl -sL https://raw.githubusercontent.com/golang/dep/v${DEP_VERSION}/install.sh | sh \
# Configure vi environment
&& mkdir -p /home/${user}/.vim/pack/plugins/start \
&& mkdir -p /home/${user}/.vim/syntax \
&& rm /usr/bin/vi && ln -s /usr/bin/vim /usr/bin/vi \
&& git clone https://github.com/fatih/vim-go.git /home/${user}/.vim/pack/plugins/start/vim-go \
&& git clone https://github.com/manniwood/vim-buf.git /home/${user}/.vim/pack/plugins/start/vim-buf \
&& git clone https://github.com/hashivim/vim-terraform.git /home/${user}/.vim/pack/plugins/start/vim-terraform \
&& git clone https://github.com/towolf/vim-helm /home/${user}/.vim/pack/plugins/start/vim-helm \
&& go get github.com/alecthomas/gometalinter \
&& go get github.com/davidrjenni/reftools/cmd/fillstruct \
&& go get github.com/davidrjenni/reftools/cmd/fillswitch \
&& go get github.com/davidrjenni/reftools/cmd/fixplurals \
&& go get github.com/fatih/gomodifytags \
&& go get github.com/fatih/motion \
&& go get github.com/josharian/impl \
&& go get github.com/jstemmer/gotags \
&& go get github.com/kisielk/errcheck \
&& go get github.com/klauspost/asmfmt/cmd/asmfmt \
&& go get github.com/koron/iferr \
&& go get github.com/rogpeppe/godef \
&& go get github.com/stamblerre/gocode \
&& go get github.com/stamblerre/gocode \
&& go get github.com/zmb3/gogetdoc \
&& go get golang.org/x/lint/golint \
&& go get golang.org/x/tools/cmd/goimports \
&& GO111MODULE=on go get golang.org/x/tools/gopls@${GOPLS_VERSION} \
&& go get golang.org/x/tools/cmd/guru \
&& go get honnef.co/go/tools/cmd/keyify \
&& GO111MODULE=on go get github.com/mikefarah/yq/v3 \
&& git clone https://github.com/robbyrussell/oh-my-zsh /home/${user}/.oh-my-zsh \
&& chown -R ${user}:${group} /home/${user}
ADD --chown=1000:wheel env/motd /etc/motd
ADD --chown=1000:wheel env/vim /home/${user}/.vim
ADD --chown=1000:wheel env/vimrc /home/${user}/.vimrc
ADD --chown=1000:wheel env/${SHELL}/${SHELL}rc /home/${user}/.${SHELL}rc
ADD --chown=1000:wheel env/tmux.conf /home/${user}/.tmux.conf
ADD --chown=1000:wheel env/${SHELL}/tmux.conf.local /home/${user}/.tmux.conf.local
# Setup Environment
USER ${user}
EXPOSE 1313
EXPOSE 2345
EXPOSE 8080
ENV PATH /home/${user}/bin:$PATH
WORKDIR /home/$user/go-workspace
CMD /bin/${SHELL}
COPY --from=jx /usr/bin/jx /usr/local/bin/jx