Do not preserve SAP JVM archive owner
[mbt-docker.git] / Dockerfile
... / ...
CommitLineData
1FROM debian:bullseye-slim
2
3ARG USER="mta"
4ARG USER_HOME_DIR="/home/${USER}"
5ENV HOME ${USER_HOME_DIR}
6
7RUN set -ex \
8 && apt-get update \
9 && apt-get install -y openssl --no-install-recommends \
10 && rm -rf /var/lib/apt/lists/* \
11 # smoke test
12 && openssl version \
13 && useradd --home-dir ${USER_HOME_DIR} \
14 --create-home \
15 --shell /bin/bash \
16 --user-group \
17 --uid 1000 \
18 --comment 'Cloud MTA Build Tool' \
19 --password "$(echo weUseMta | openssl passwd -1 -stdin)" ${USER} \
20 # allow anybody to write into the image user home directory
21 && chmod a+w ${USER_HOME_DIR} \
22 && apt-get remove --purge --autoremove -y openssl
23
24ADD http://aia.pki.co.sap.com/aia/SAP%20Global%20Root%20CA.crt \
25 /etc/ssl/certs/SAP_Global_Root_CA.crt
26
27ARG NODE_VERSION=16.19.0
28
29RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
30 && case "${dpkgArch##*-}" in \
31 amd64) ARCH='x64';; \
32 ppc64el) ARCH='ppc64le';; \
33 s390x) ARCH='s390x';; \
34 arm64) ARCH='arm64';; \
35 armhf) ARCH='armv7l';; \
36 i386) ARCH='x86';; \
37 *) echo "unsupported architecture"; exit 1 ;; \
38 esac \
39 && set -ex \
40 && apt-get update \
41 # libatomic1 for arm
42 && apt-get install -y ca-certificates curl gnupg dirmngr xz-utils libatomic1 --no-install-recommends \
43 && rm -rf /var/lib/apt/lists/* \
44 && export GNUPGHOME="$(mktemp -d)" \
45 && for key in \
46 4ED778F539E3634C779C87C6D7062848A1AB005C \
47 141F07595B7B3FFE74309A937405533BE57C7D57 \
48 74F12602B6F1C4E913FAA37AD3A89613643B6201 \
49 61FC681DFB92A079F1685E77973F295594EC4689 \
50 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
51 C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
52 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
53 C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
54 108F52B48DB57BB0CC439B2997B01419BD92F80A \
55 ; do \
56 gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
57 gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
58 done \
59 && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
60 && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
61 && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
62 && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
63 && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
64 && rm -rf "$GNUPGHOME" "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
65 && apt-mark auto '.*' > /dev/null \
66 && find /usr/local -type f -executable -exec ldd '{}' ';' \
67 | awk '/=>/ { print $(NF-1) }' \
68 | sort -u \
69 | xargs -r dpkg-query --search \
70 | cut -d: -f1 \
71 | sort -u \
72 | xargs -r apt-mark manual \
73 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
74 && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
75 # smoke tests
76 && node --version \
77 && npm --version
78
79ARG YARN_VERSION=1.22.19
80
81RUN set -ex \
82 && savedAptMark="$(apt-mark showmanual)" \
83 && apt-get update \
84 && apt-get install -y ca-certificates curl gnupg dirmngr --no-install-recommends \
85 && rm -rf /var/lib/apt/lists/* \
86 && export GNUPGHOME="$(mktemp -d)" \
87 && for key in \
88 6A010C5166006599AA17F08146C2130DFD2497F5 \
89 ; do \
90 gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
91 gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
92 done \
93 && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
94 && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
95 && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
96 && mkdir -p /opt \
97 && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
98 && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
99 && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
100 && rm -rf "$GNUPGHOME" yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
101 && apt-mark auto '.*' > /dev/null \
102 && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; } \
103 && find /usr/local -type f -executable -exec ldd '{}' ';' \
104 | awk '/=>/ { print $(NF-1) }' \
105 | sort -u \
106 | xargs -r dpkg-query --search \
107 | cut -d: -f1 \
108 | sort -u \
109 | xargs -r apt-mark manual \
110 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
111 # smoke test
112 && yarn --version
113
114ARG SAPMACHINE_VERSION=11.0.17
115
116ENV JAVA_HOME /opt/jdk
117
118RUN sapmachine_install() { \
119 SAPMACHINE_MAJOR_VERSION=$(echo ${SAPMACHINE_VERSION} | cut -d. -f1); \
120 ARCH=; \
121 dpkgArch="$(dpkg --print-architecture)"; \
122 case "${dpkgArch##*-}" in \
123 amd64) ARCH='amd64';; \
124 *) echo "unsupported architecture"; exit 1 ;; \
125 esac; \
126 apt-get update; \
127 apt-get install -y ca-certificates gnupg dirmngr --no-install-recommends; \
128 rm -rf /var/lib/apt/lists/*; \
129 export GNUPGHOME="$(mktemp -d)"; \
130 for key in \
131 CACB9FE09150307D1D22D82962754C3B3ABCFE23 \
132 ; do \
133 gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
134 gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
135 done; \
136 chmod 644 /etc/apt/trusted.gpg.d/sapmachine.gpg; \
137 echo "deb http://dist.sapmachine.io/debian/${ARCH}/ ./" | tee /etc/apt/sources.list.d/sapmachine.list; \
138 apt-get update; \
139 apt-get install -y sapmachine-${SAPMACHINE_MAJOR_VERSION}-jdk=${SAPMACHINE_VERSION} --no-install-recommends; \
140 rm -rf "$GNUPGHOME" /var/lib/apt/lists/*; \
141 apt-get remove --purge --autoremove -y ca-certificates gnupg dirmngr; \
142 ln -s /usr/lib/jvm/sapmachine-${SAPMACHINE_MAJOR_VERSION} ${JAVA_HOME}; \
143 }; \
144 sapjvm_install() { \
145 ARCH=; \
146 dpkgArch="$(dpkg --print-architecture)"; \
147 case "${dpkgArch##*-}" in \
148 amd64) ARCH='x64';; \
149 ppc64el) ARCH='ppc64le';; \
150 *) echo "unsupported architecture"; exit 1 ;; \
151 esac; \
152 apt-get update; \
153 apt-get install -y ca-certificates curl libarchive-tools --no-install-recommends; \
154 rm -rf /var/lib/apt/lists/*; \
155 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; \
156 echo "583dedfeee0c119839a610ddc8c6768d0c044429 sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip" | sha1sum -c -; \
157 bsdtar -xvf sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip -C /usr/local --strip-components=1 --no-same-owner; \
158 rm -f sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip; \
159 apt-get remove --purge --auto-remove -y ca-certificates curl libarchive-tools; \
160 ln -s /usr/local ${JAVA_HOME}; \
161 } \
162 && set -ex \
163 && if [ $(echo ${SAPMACHINE_VERSION} | cut -d. -f1) -le 8 ]; then \
164 sapjvm_install; \
165 else \
166 sapmachine_install; \
167 fi \
168 # smoke test
169 && java -version
170
171ARG MAVEN_VERSION=3.8.6
172ARG BASE_URL=https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
173
174ENV MAVEN_HOME /usr/share/maven
175ENV M2_HOME ${MAVEN_HOME}
176
177RUN set -ex \
178 && apt-get update \
179 && apt-get install -y ca-certificates curl gnupg dirmngr --no-install-recommends \
180 && rm -rf /var/lib/apt/lists/* \
181 && curl -fsSLO --compressed ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
182 && curl -fsSLO --compressed ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc \
183 && export GNUPGHOME="$(mktemp -d)" \
184 && for key in \
185 6A814B1F869C2BBEAB7CB7271A2A1C94BDE89688 \
186 ; do \
187 gpg --batch --keyserver hkps://pgp.surf.nl --recv-keys "$key" || \
188 gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
189 done \
190 && gpg --batch --verify apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc apache-maven-${MAVEN_VERSION}-bin.tar.gz \
191 && mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref \
192 && tar -xzf apache-maven-${MAVEN_VERSION}-bin.tar.gz -C ${MAVEN_HOME} --strip-components=1 \
193 && rm -rf "$GNUPGHOME" apache-maven-${MAVEN_VERSION}-bin.tar.gz.asc apache-maven-${MAVEN_VERSION}-bin.tar.gz \
194 && chmod -R a+w ${MAVEN_HOME}/conf/* \
195 && ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn \
196 && apt-get remove --purge --autoremove -y ca-certificates curl gnupg dirmngr \
197 # smoke test
198 && mvn --version
199
200ARG MBT_VERSION=1.2.21
201
202RUN set -ex \
203 && npm install -g --registry=https://int.repositories.cloud.sap/artifactory/api/npm/build-releases-npm --unsafe-perm mbt@${MBT_VERSION} \
204 && npm cache clean -g --force \
205 # smoke test
206 && mbt --version
207
208# SAP e-Mobility requirements
209RUN set -ex \
210 && apt-get update \
211 && apt-get install -y ca-certificates build-essential python3 --no-install-recommends \
212 && rm -rf /var/lib/apt/lists/* \
213 # smoke test
214 && python3 --version
215
216WORKDIR /project
217USER ${USER}