Skip to content

Commit 7cf7979

Browse files
young-yang03Young Yang
andauthored
MBT Java 8 Docker Image (#1023)
* modified: Dockerfile_mbtci_template modified: cmd/testdata/mtahtml5/mta.sh modified: integration/testdata/mtahtml5/mta.sh modified: scripts/build_image modified: scripts/common_image * modified: .circleci/config.yml * modified: Dockerfile_mbtci_template * modified: Dockerfile_mbtci_template * modified: Dockerfile_mbtci_template modified: test/goss/goss_template.yaml --------- Co-authored-by: Young Yang <young.yang03@sap.com>
1 parent 555577f commit 7cf7979

File tree

7 files changed

+209
-36
lines changed

7 files changed

+209
-36
lines changed

.circleci/config.yml

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
command: |
5353
go mod vendor
5454
- run: cf login -a $CF_API -o $ORG -s $SPACE -u $TECH_USER -p $TECH_PASS
55-
- run: cd integration && go test -tags=integration
55+
- run: cd integration && go test -tags=integration
5656

5757
compliance:
5858
docker:
@@ -139,6 +139,102 @@ jobs:
139139
export GITHUB_TOKEN=${CLOUD_MTA_BOT_GITHUB_TOKEN}
140140
curl -sfL https://goreleaser.com/static/run | bash
141141
142+
publish-to-dockerhub-java8-node14:
143+
docker:
144+
- image: cimg/go:1.17
145+
working_directory: ~/go/src/github.com/young-yang03/cloud-mta-build-tool
146+
steps:
147+
- checkout
148+
- setup_remote_docker:
149+
version: 20.10.6
150+
- run:
151+
name: build image pre-setup
152+
command: |
153+
#Make sure HEAD points to master
154+
git checkout master
155+
git fetch
156+
git rebase
157+
- run:
158+
name: build Java 8.1.091 & Node 14.21.1 image
159+
command: |
160+
MBT_VERSION=$(cat ./VERSION)
161+
sh $PWD/scripts/build_image 8.1.091 14.21.1 ${MBT_VERSION}
162+
- run:
163+
name: publish Java 8.1.091 & Node 14.21.1 image
164+
command: |
165+
MBT_VERSION=$(cat ./VERSION)
166+
echo "Image release: ${MBT_VERSION}"
167+
#Push to Docker Hub
168+
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
169+
sh $PWD/scripts/publish_image 8.1.091 14.21.1 ${MBT_VERSION} "cobra217"
170+
#Push to GitHub Container Registry
171+
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
172+
sh $PWD/scripts/publish_image 8.1.091 14.21.1 ${MBT_VERSION} "ghcr.io/young-yang03"
173+
174+
publish-to-dockerhub-java8-node16:
175+
docker:
176+
- image: cimg/go:1.17
177+
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
178+
steps:
179+
- checkout
180+
- setup_remote_docker:
181+
version: 20.10.6
182+
- run:
183+
name: build image pre-setup
184+
command: |
185+
#Make sure HEAD points to master
186+
git checkout master
187+
git fetch
188+
git rebase
189+
- run:
190+
name: build Java 8.1.091 & Node 16.18.1 image
191+
command: |
192+
MBT_VERSION=$(cat ./VERSION)
193+
sh $PWD/scripts/build_image 8.1.091 16.18.1 ${MBT_VERSION}
194+
- run:
195+
name: publish Java 8.1.091 & Node 16.18.1 image
196+
command: |
197+
MBT_VERSION=$(cat ./VERSION)
198+
echo "Image release: ${MBT_VERSION}"
199+
#Push to Docker Hub
200+
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
201+
sh $PWD/scripts/publish_image 8.1.091 16.18.1 ${MBT_VERSION} "cobra217"
202+
#Push to GitHub Container Registry
203+
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
204+
sh $PWD/scripts/publish_image 8.1.091 16.18.1 ${MBT_VERSION} "ghcr.io/young-yang03"
205+
206+
publish-to-dockerhub-java8-node18:
207+
docker:
208+
- image: cimg/go:1.17
209+
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
210+
steps:
211+
- checkout
212+
- setup_remote_docker:
213+
version: 20.10.6
214+
- run:
215+
name: build image pre-setup
216+
command: |
217+
#Make sure HEAD points to master
218+
git checkout master
219+
git fetch
220+
git rebase
221+
- run:
222+
name: build Java 8.1.091 & Node 18.12.1 image
223+
command: |
224+
MBT_VERSION=$(cat ./VERSION)
225+
sh $PWD/scripts/build_image 8.1.091 18.12.1 ${MBT_VERSION}
226+
- run:
227+
name: publish Java 8.1.091 & Node 18.12.1 image
228+
command: |
229+
MBT_VERSION=$(cat ./VERSION)
230+
echo "Image release: ${MBT_VERSION}"
231+
#Push to Docker Hub
232+
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
233+
sh $PWD/scripts/publish_image 8.1.091 18.12.1 ${MBT_VERSION} "cobra217"
234+
#Push to GitHub Container Registry
235+
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
236+
sh $PWD/scripts/publish_image 8.1.091 18.12.1 ${MBT_VERSION} "ghcr.io/young-yang03"
237+
142238
publish-to-dockerhub-java11-node14:
143239
docker:
144240
- image: cimg/go:1.17
@@ -157,8 +253,8 @@ jobs:
157253
- run:
158254
name: build Java 11.0.17 & Node 14.21.1 image
159255
command: |
160-
MBT_VERSION=$(cat ./VERSION)
161-
sh $PWD/scripts/build_image 11.0.17 14.21.1 ${MBT_VERSION}
256+
MBT_VERSION=$(cat ./VERSION)
257+
sh $PWD/scripts/build_image 11.0.17 14.21.1 ${MBT_VERSION}
162258
- run:
163259
name: publish Java 11.0.17 & Node 14.21.1 image
164260
command: |
@@ -553,6 +649,30 @@ workflows:
553649
only: /release/
554650
branches:
555651
ignore: /.*/
652+
- publish-to-dockerhub-java8-node14:
653+
requires:
654+
- publish-to-npm
655+
filters:
656+
tags:
657+
only: /release/
658+
branches:
659+
ignore: /.*/
660+
- publish-to-dockerhub-java8-node16:
661+
requires:
662+
- publish-to-npm
663+
filters:
664+
tags:
665+
only: /release/
666+
branches:
667+
ignore: /.*/
668+
- publish-to-dockerhub-java8-node18:
669+
requires:
670+
- publish-to-npm
671+
filters:
672+
tags:
673+
only: /release/
674+
branches:
675+
ignore: /.*/
556676
- publish-to-dockerhub-java11-node14:
557677
requires:
558678
- publish-to-npm
@@ -627,6 +747,9 @@ workflows:
627747
ignore: /.*/
628748
- remove-github-release-tag:
629749
requires:
750+
- publish-to-dockerhub-java8-node14
751+
- publish-to-dockerhub-java8-node16
752+
- publish-to-dockerhub-java8-node18
630753
- publish-to-dockerhub-java11-node14
631754
- publish-to-dockerhub-java11-node16
632755
- publish-to-dockerhub-java11-node18

Dockerfile_mbtci_template

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ ARG MTA_USER_HOME="/home/${MTA_USER}"
66
ARG MBT_VERSION=1.2.21
77
ARG GO_VERSION=1.19.3
88
ARG NODE_VERSION=NODE_VERSION_TEMPLATE
9-
ARG MAVEN_VERSION=3.8.6
9+
ARG MAVEN_VERSION=3.8.7
1010
ARG MAVEN_BASE_URL=https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
1111
ARG SAPMACHINE_VERSION=JAVA_VERSION_TEMPLATE
1212

1313
# Environment variables
1414
ENV PYTHON /usr/bin/python3
15+
ENV JAVA_HOME /opt/jdk
1516
ENV MAVEN_HOME /usr/share/maven
1617
ENV M2_HOME ${MAVEN_HOME}
1718
ENV PATH /usr/local/go/bin:$PATH
@@ -72,12 +73,12 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
7273
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
7374
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
7475
done \
75-
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
76-
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
76+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" \
77+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt.asc" \
7778
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
78-
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
79-
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
80-
&& rm -rf "$GNUPGHOME" "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
79+
&& grep " node-v${NODE_VERSION}-linux-${ARCH}.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
80+
&& tar -xJf "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
81+
&& rm -rf "$GNUPGHOME" "node-v${NODE_VERSION}-linux-${ARCH}.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
8182
&& apt-mark auto '.*' > /dev/null \
8283
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
8384
| awk '/=>/ { print $(NF-1) }' \
@@ -143,31 +144,59 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
143144
&& go version
144145

145146
# Install SAPMachine
146-
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
147-
&& case "${dpkgArch##*-}" in \
147+
RUN sapmachine_install() { \
148+
SAPMACHINE_MAJOR_VERSION=$(echo ${SAPMACHINE_VERSION} | cut -d. -f1); \
149+
ARCH=; \
150+
dpkgArch="$(dpkg --print-architecture)"; \
151+
case "${dpkgArch##*-}" in \
148152
amd64) ARCH='amd64';; \
149153
*) echo "unsupported architecture"; exit 1 ;; \
150-
esac \
154+
esac; \
155+
apt-get update; \
156+
apt-get install -y ca-certificates gnupg dirmngr --no-install-recommends; \
157+
rm -rf /var/lib/apt/lists/*; \
158+
export GNUPGHOME="$(mktemp -d)"; \
159+
for key in \
160+
CACB9FE09150307D1D22D82962754C3B3ABCFE23 \
161+
; do \
162+
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
163+
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
164+
done; \
165+
chmod 644 /etc/apt/trusted.gpg.d/sapmachine.gpg; \
166+
echo "deb http://dist.sapmachine.io/debian/${ARCH}/ ./" | tee /etc/apt/sources.list.d/sapmachine.list; \
167+
apt-get update; \
168+
apt-get install -y sapmachine-${SAPMACHINE_MAJOR_VERSION}-jdk=${SAPMACHINE_VERSION} --no-install-recommends; \
169+
rm -rf "$GNUPGHOME" /var/lib/apt/lists/*; \
170+
apt-get remove --purge --autoremove -y ca-certificates gnupg dirmngr; \
171+
ln -s /usr/lib/jvm/sapmachine-${SAPMACHINE_MAJOR_VERSION} ${JAVA_HOME}; \
172+
}; \
173+
sapjvm_install() { \
174+
ARCH=; \
175+
dpkgArch="$(dpkg --print-architecture)"; \
176+
case "${dpkgArch##*-}" in \
177+
amd64) ARCH='x64';; \
178+
ppc64el) ARCH='ppc64le';; \
179+
*) echo "unsupported architecture"; exit 1 ;; \
180+
esac; \
181+
apt-get update; \
182+
apt-get install -y ca-certificates curl libarchive-tools --no-install-recommends; \
183+
rm -rf /var/lib/apt/lists/*; \
184+
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; \
185+
echo "583dedfeee0c119839a610ddc8c6768d0c044429 sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip" | sha1sum -c -; \
186+
bsdtar -xvf sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip -C /usr/local --strip-components=1 --no-same-owner; \
187+
rm -f sapjvm-${SAPMACHINE_VERSION}-linux-${ARCH}.zip; \
188+
apt-get remove --purge --auto-remove -y ca-certificates curl libarchive-tools; \
189+
ln -s /usr/local ${JAVA_HOME}; \
190+
} \
151191
&& set -ex \
152-
&& apt-get update \
153-
&& apt-get install -y ca-certificates gnupg dirmngr --no-install-recommends \
154-
&& rm -rf /var/lib/apt/lists/* \
155-
&& export GNUPGHOME="$(mktemp -d)" \
156-
&& for key in \
157-
CACB9FE09150307D1D22D82962754C3B3ABCFE23 \
158-
; do \
159-
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
160-
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/sapmachine.gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys "$key" ; \
161-
done \
162-
&& chmod 644 /etc/apt/trusted.gpg.d/sapmachine.gpg \
163-
&& echo "deb http://dist.sapmachine.io/debian/${ARCH}/ ./" | tee /etc/apt/sources.list.d/sapmachine.list \
164-
&& apt-get update \
165-
&& apt-get install -y sapmachine-$(echo ${SAPMACHINE_VERSION} | cut -d. -f1)-jdk=${SAPMACHINE_VERSION} --no-install-recommends \
166-
&& rm -rf "$GNUPGHOME" /var/lib/apt/lists/* \
167-
&& apt-get remove --purge --autoremove -y ca-certificates gnupg dirmngr \
192+
&& if [ $(echo ${SAPMACHINE_VERSION} | cut -d. -f1) -le 8 ]; then \
193+
sapjvm_install; \
194+
else \
195+
sapmachine_install; \
196+
fi \
168197
# smoke test
169198
&& echo "SAPMachine ${SAPMACHINE_VERSION} install smoke test!" \
170-
&& java --version
199+
&& java -version
171200

172201
# Install Maven
173202
RUN set -ex \
@@ -212,6 +241,13 @@ RUN set -ex \
212241
&& python2.7 --version \
213242
&& python3 --version
214243

215-
ENV PATH=$PATH:./node_modules/.bin HOME=${MTA_USER_HOME}
244+
# Allow global npm packages install without sudo
245+
RUN set -ex \
246+
&& mkdir ${MTA_USER_HOME}/.npm-global \
247+
&& mkdir ${MTA_USER_HOME}/.npm-global/lib \
248+
&& chown -R ${MTA_USER}:${MTA_USER} ${MTA_USER_HOME}
249+
ENV NPM_CONFIG_PREFIX ${MTA_USER_HOME}/.npm-global
250+
251+
ENV PATH=$PATH:./node_modules/.bin:${MTA_USER_HOME}/.npm-global/bin
216252
WORKDIR /project
217253
USER ${MTA_USER}

cmd/testdata/mtahtml5/mta.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# ----Executing build for module ui5app -------
1818
# installing module dependencies & execute grunt & remove dev dependencies
19-
(npm install && grunt && npm prune production ) &
19+
(npm install && grunt && npm prune production) &
2020
# wait to the process to finish
2121
wait
2222
# Pack module after build for deployment

integration/testdata/mtahtml5/mta.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# ----Executing build for module ui5app -------
1818
# installing module dependencies & execute grunt & remove dev dependencies
19-
(npm install && grunt && npm prune production ) &
19+
(npm install && grunt && npm prune production) &
2020
# wait to the process to finish
2121
wait
2222
# Pack module after build for deployment

scripts/build_image

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ echo "Build mbtci${JAVA_VERSION}${NODE_VERSION}:${MBT_VERSION}"
1919
docker build -t mbtci${JAVA_VERSION}${NODE_VERSION}:${MBT_VERSION} .
2020

2121
# test image
22-
if [ "$JAVA_MAJOR_VERSION" = "11" ] || [ "$JAVA_MAJOR_VERSION" = "17" ] || [ "$JAVA_MAJOR_VERSION" = "19" ]; then
22+
if [ "$JAVA_MAJOR_VERSION" = "8" ] || [ "$JAVA_MAJOR_VERSION" = "11" ] || \
23+
[ "$JAVA_MAJOR_VERSION" = "17" ] || [ "$JAVA_MAJOR_VERSION" = "19" ]; then
2324
cp test/goss/goss_template.yaml test/goss/goss.yaml
2425
sed_i "s/NODE_VERSION_TEMPLATE/${NODE_VERSION_TEMPLATE}/" test/goss/goss.yaml
2526
sed_i "s/JAVA_VERSION_TEMPLATE/${JAVA_VERSION_TEMPLATE}/" test/goss/goss.yaml

scripts/common_image

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export NODE_MAJOR_VERSION="$(echo ${NODE_VERSION_TEMPLATE}|awk -F. '{printf "%d"
1111

1212
echo "Java major version: ${JAVA_MAJOR_VERSION}, Node major version: ${NODE_MAJOR_VERSION}"
1313

14-
if ([ "$JAVA_MAJOR_VERSION" -ne "11" ] && [ "$JAVA_MAJOR_VERSION" -ne "17" ] && [ "$JAVA_MAJOR_VERSION" -ne "19" ]) || \
14+
if ([ "$JAVA_MAJOR_VERSION" -ne "8" ] && [ "$JAVA_MAJOR_VERSION" -ne "11" ] && [ "$JAVA_MAJOR_VERSION" -ne "17" ] && [ "$JAVA_MAJOR_VERSION" -ne "19" ]) || \
1515
([ "$NODE_MAJOR_VERSION" -ne "14" ] && [ "$NODE_MAJOR_VERSION" -ne "16" ] && [ "$NODE_MAJOR_VERSION" -ne "18" ])
1616
then
1717
echo "Java: ${JAVA_MAJOR_VERSION}, Node: ${NODE_MAJOR_VERSION} combination is not supported!"

test/goss/goss_template.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ package:
99
installed: true
1010
python3:
1111
installed: true
12-
make:
13-
installed: true
1412
user:
1513
mta:
1614
exists: true
@@ -41,6 +39,15 @@ command:
4139
exit-status: 0
4240
stdout:
4341
- vNODE_VERSION_TEMPLATE
42+
# verify installed UI5
43+
ui5 --version:
44+
exit-status: 0
45+
# verify installed grunt
46+
grunt --version:
47+
exit-status: 0
48+
# verify installed go
49+
go version:
50+
exit-status:0
4451
# verify NPM @sap-scope registry NOT configured
4552
npm config get @sap:registry:
4653
exit-status: 0
@@ -54,3 +61,9 @@ command:
5461
cd ~ && npm install @sap/cds:
5562
exit-status: 0
5663
timeout: 50000
64+
cd ~ && npm install -g @sap/cds:
65+
exit-status: 0
66+
timeout: 50000
67+
cd ~ && npm link @sap/cds --local:
68+
exit-status: 0
69+
timeout: 50000

0 commit comments

Comments
 (0)