forked from cvakiitho/cloud-mta-build-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
259 lines (244 loc) · 10.5 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
FROM debian:bullseye-slim
# Build time arguments
ARG MTA_USER="mta"
ARG MTA_USER_HOME="/home/${MTA_USER}"
ARG MBT_VERSION=1.2.25
ARG GO_VERSION=1.21.0
ARG NODE_VERSION=NODE_VERSION_TEMPLATE
ARG MAVEN_VERSION=3.6.0
ARG UI5_VERSION=2.14.19
ARG MAVEN_BASE_URL=https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
ARG SAPMACHINE_VERSION=JAVA_VERSION_TEMPLATE
# Environment variables
ENV PYTHON /usr/bin/python3
ENV JAVA_HOME /opt/jdk
ENV MAVEN_HOME /usr/share/maven
ENV M2_HOME ${MAVEN_HOME}
ENV PATH /usr/local/go/bin:$PATH
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV DEBIAN_FRONTEND=noninteractive
# Create user account and using openssl to create password
RUN set -ex \
&& apt-get update \
&& apt-get install -y openssl --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
# smoke test
&& openssl version \
&& useradd --home-dir ${MTA_USER_HOME} \
--create-home \
--shell /bin/bash \
--user-group \
--uid 1000 \
--comment 'Cloud MTA Build Tool' \
--password "$(echo weUseMta | openssl passwd -1 -stdin)" ${MTA_USER} \
# allow anybody to write into the image user home directory
&& chmod a+w ${MTA_USER_HOME} \
&& apt-get remove --purge --autoremove -y openssl
# Download SAP_Global_Root_CA.crt to target
ADD http://aia.pki.co.sap.com/aia/SAP%20Global%20Root%20CA.crt \
/etc/ssl/certs/SAP_Global_Root_CA.crt
# Install Node.js
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& set -ex \
&& apt-get update \
# libatomic1 for arm
&& apt-get install -y ca-certificates curl gnupg dirmngr xz-utils libatomic1 --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
141F07595B7B3FFE74309A937405533BE57C7D57 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm -rf "$GNUPGHOME" "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& apt-mark auto '.*' > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
# smoke tests
&& echo "node ${NODE_VERSION} install smoke tests!" \
&& node --version \
&& npm --version
# Install Grunt CLI
RUN set -ex \
&& npm install --prefix /usr/local/ -g grunt-cli \
&& npm cache clean -g --force \
# smoke test
&& echo "grunt-cli install smoke test!" \
&& grunt --version
# Install UI5 CLI
RUN set -ex \
&& npm install --prefix /usr/local/ -g @ui5/cli@${UI5_VERSION} \
&& npm cache clean -g --force \
# smoke test
&& echo "ui5 install smoke test!" \
&& ui5 --version
# Install Golang
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
i386) ARCH='386';; \
amd64) ARCH='amd64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv6l';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& set -ex \
&& apt-get update \
&& apt-get install -y ca-certificates curl gnupg dirmngr --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796 \
2F528D36D67B69EDF998D85778BD65473CB3BD13 \
; do \
gpg --batch --keyserver hkps://pgp.surf.nl --recv-keys "$key" || \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed https://storage.googleapis.com/golang/go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz \
&& curl -fsSLO --compressed https://storage.googleapis.com/golang/go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz.asc \
&& gpg --batch --verify go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz.asc go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz \
&& tar -xvf go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz -C /usr/local \
&& rm -rf "$GNUPGHOME" go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz go${GO_VERSION}.${GOOS}-${ARCH}.tar.gz.asc \
&& apt-get remove --purge --autoremove -y ca-certificates curl gnupg dirmngr \
# smoke test
&& echo "go ${GO_VERSION} install smoke test!" \
&& go version
# Install SAPMachine
RUN sapmachine_install() { \
SAPMACHINE_MAJOR_VERSION=$(echo ${SAPMACHINE_VERSION} | cut -d. -f1); \
ARCH=; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) ARCH='amd64';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac; \
apt-get update; \
apt-get install -y ca-certificates gnupg dirmngr --no-install-recommends; \
rm -rf /var/lib/apt/lists/*; \
export GNUPGHOME="$(mktemp -d)"; \
for key in \
CACB9FE09150307D1D22D82962754C3B3ABCFE23 \
; do \
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
done; \
chmod 644 /etc/apt/trusted.gpg.d/sapmachine.gpg; \
echo "deb http://dist.sapmachine.io/debian/${ARCH}/ ./" | tee /etc/apt/sources.list.d/sapmachine.list; \
apt-get update; \
apt-get install -y sapmachine-${SAPMACHINE_MAJOR_VERSION}-jdk=${SAPMACHINE_VERSION} --no-install-recommends; \
rm -rf "$GNUPGHOME" /var/lib/apt/lists/*; \
apt-get remove --purge --autoremove -y ca-certificates gnupg dirmngr; \
ln -s /usr/lib/jvm/sapmachine-${SAPMACHINE_MAJOR_VERSION} ${JAVA_HOME}; \
}; \
sapjvm_install() { \
ARCH=; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac; \
apt-get update; \
apt-get install -y ca-certificates curl libarchive-tools --no-install-recommends; \
rm -rf /var/lib/apt/lists/*; \
curl -fsSLO --compressed -b 'eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt' https://tools.hana.ondemand.com/additional/sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip; \
echo "7d63f20b17becb5f658d413c113ea9efdfbba6a0 sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip" | sha1sum -c -; \
bsdtar -xvf sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip -C /usr/local --strip-components=1 --no-same-owner; \
rm -f sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip; \
apt-get remove --purge --auto-remove -y ca-certificates curl libarchive-tools; \
ln -s /usr/local ${JAVA_HOME}; \
} \
&& set -ex \
&& if [ $(echo ${SAPMACHINE_VERSION} | cut -d. -f1) -le 8 ]; then \
sapjvm_install; \
else \
sapmachine_install; \
fi \
# smoke test
&& echo "SAPMachine ${SAPMACHINE_VERSION} install smoke test!" \
&& java -version
# Install Maven
RUN set -ex \
&& apt-get update \
&& apt-get install -y ca-certificates curl gnupg dirmngr --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSLO --compressed ${MAVEN_BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& curl -fsSLO --compressed ${MAVEN_BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
29BEA2A645F2D6CED7FB12E02B172E3E156466E8 \
; do \
gpg --batch --keyserver hkps://pgp.surf.nl --recv-keys "$key" || \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --batch --verify apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref \
&& tar -xzf apache-maven-${MAVEN_VERSION}-bin.tar.gz -C ${MAVEN_HOME} --strip-components=1 \
&& rm -rf "$GNUPGHOME" apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& chmod -R a+w ${MAVEN_HOME}/conf/* \
&& ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn \
&& apt-get remove --purge --autoremove -y ca-certificates curl gnupg dirmngr \
# smoke test
&& echo "mvn ${MAVEN_VERSION} install smoke test!" \
&& mvn --version
# Install MBT
RUN set -ex \
&& npm install -g --unsafe-perm mbt@${MBT_VERSION} \
&& npm cache clean -g --force \
# smoke test
&& echo "mbt ${MBT_VERSION} install smoke test!" \
&& mbt --version
# Install essential build tools and Python
RUN set -ex \
&& apt-get update \
&& apt-get install -y ca-certificates build-essential git python2.7 python3 --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
# smoke tests
&& echo "python install smoke tests!" \
&& python2.7 --version \
&& python3 --version
# Allow global npm packages install without sudo
RUN set -ex \
&& mkdir ${MTA_USER_HOME}/.npm-global \
&& mkdir ${MTA_USER_HOME}/.npm-global/lib \
&& chown -R ${MTA_USER}:${MTA_USER} ${MTA_USER_HOME}
ENV NPM_CONFIG_PREFIX ${MTA_USER_HOME}/.npm-global
# Instll curl and ca-certificates
RUN set -ex \
&& apt-get update \
&& apt-get install -y curl ca-certificates --no-install-recommends
ENV PATH=$PATH:./node_modules/.bin:${MTA_USER_HOME}/.npm-global/bin
WORKDIR /project
USER ${MTA_USER}