From 403c6ed0707024f6baa42635806b5299d4e68d52 Mon Sep 17 00:00:00 2001 From: Andre Voigtmann Date: Tue, 27 Sep 2022 17:43:32 +0200 Subject: [PATCH 1/1] init --- .gitignore | 2 + .xmakecfg | 11 ++++ Dockerfile | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 25 +++++++++ 4 files changed, 184 insertions(+) create mode 100644 .gitignore create mode 100644 .xmakecfg create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..337a353 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Mac OS temp files +**/.DS_Store \ No newline at end of file diff --git a/.xmakecfg b/.xmakecfg new file mode 100644 index 0000000..83e11f8 --- /dev/null +++ b/.xmakecfg @@ -0,0 +1,11 @@ +[xmake] +version=1.0.0 +# https://github.wdf.sap.corp/pages/xmake-ci/User-Guide/Setting_up_a_Build/Release_Procedure/Release_Versions/ + +[buildplugin] +# https://github.wdf.sap.corp/dtxmake/xmake +# https://github.wdf.sap.corp/pages/xmake-ci/User-Guide/Setting_up_a_Build/Build_Plugins/Docker_Build_Plugin/About_Docker_Build_Plugin/ +name=dockerbuild +bundle=true +aid=mbt-docker +gid=com.sap.emobility \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3900fcf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,146 @@ +FROM debian:bullseye-slim + +ARG USER="mta" +ARG USER_HOME_DIR="/home/${USER}" +ENV HOME ${USER_HOME_DIR} + +RUN set -ex \ + && apt-get update \ + && apt-get install -y openssl --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && useradd --home-dir ${USER_HOME_DIR} \ + --create-home \ + --shell /bin/bash \ + --user-group \ + --uid 1000 \ + --comment 'Cloud MTA Build Tool' \ + --password "$(echo weUseMta | openssl passwd -1 -stdin)" ${USER} \ + # allow anybody to write into the image user home directory + && chmod a+w ${USER_HOME_DIR} + +ADD http://aia.pki.co.sap.com/aia/SAP%20Global%20Root%20CA.crt \ + /etc/ssl/certs/SAP_Global_Root_CA.crt + +ARG NODE_VERSION=16.17.1 + +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 wget gnupg dirmngr xz-utils libatomic1 --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 141F07595B7B3FFE74309A937405533BE57C7D57 \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + 61FC681DFB92A079F1685E77973F295594EC4689 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + 890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + B9E2F5981AA6E0CD28160D9FF13993A75599653C \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver 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 "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 + && node --version \ + && npm --version + +ARG YARN_VERSION=1.22.19 + +RUN set -ex \ + && savedAptMark="$(apt-mark showmanual)" \ + && apt-get update && apt-get install -y ca-certificates curl wget gnupg dirmngr --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apt-mark auto '.*' > /dev/null \ + && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /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 \ + # smoke test + && yarn --version + +ARG MAVEN_VERSION=3.8.6 +ARG SHA=f790857f3b1f90ae8d16281f902c689e4f136ebe584aba45e4b1fa66c80cba826d3e0e52fdd04ed44b4c66f6d3fe3584a057c26dfcac544a60b301e6d0f91c26 +ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries + +ENV MAVEN_HOME /usr/share/maven +ENV M2_HOME ${MAVEN_HOME} + +RUN set -ex \ + && apt-get update \ + && apt-get install -y ca-certificates curl openjdk-11-jdk procps --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref \ + && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ + && echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ + && tar -xzf /tmp/apache-maven.tar.gz -C ${MAVEN_HOME} --strip-components=1 \ + && rm -f /tmp/apache-maven.tar.gz \ + && ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn \ + && chmod --recursive a+w "${MAVEN_HOME}"/conf/* \ + && apt-get remove --purge --autoremove -y curl \ + # smoke tests + && java --version \ + && mvn --version + +# Install SAP e-Mobility requirements +RUN set -ex \ + && apt-get update \ + && apt-get install -y build-essential python3 --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && npm install -g mbt \ + # smoke test + && mbt --version + +WORKDIR /project +USER ${USER} diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a493f6 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# mbt-docker +## Links + +- [ProjectPortal](https://projectportal.tools.sap/#/projectview/ght-e-mobility-mbt-docker) +- [xMake](https://xmake-nova.wdf.sap.corp/job_finder/?input=ght-e-mobility-mbt-docker-OD-common) +- [Artifactory](https://int.repositories.cloud.sap/ui/packages/docker:%2F%2Fcom.sap.emobility%2Fmbtbuildimage?name=com.sap.emobility&type=packages) + +## One-Time Setup Setup +Register Project Portal +- https://github.wdf.sap.corp/pages/xmake-ci/User-Guide/Setting_up_a_Build/Create_a_Github_project/#default-builds +- https://projectportal.tools.sap/#/availableTemplates +- https://github.tools.sap/E-Mobility/mbt-docker/blob/config/services/production-services/build-service/config.yml + +## How-To Build docker image + +- Make sure the latest `main` branch version in [.xmake.cfg](https://github.tools.sap/E-Mobility/mbt-docker/blob/main/.xmake.cfg) + is higher than the latest published version on + [Artifactory](https://int.repositories.cloud.sap/ui/packages/docker:%2F%2Fcom.sap.emobility%2Fmbtbuildimage?name=com.sap.emobility&type=packages) +- Open [xMake](https://xmake-nova.wdf.sap.corp/job_finder/?input=ght-e-mobility-mbt-docker-OD-common) +- Click _Build with Parameters_ +- Change _TREEISH_ to `master` +- Change _BUILD_DEPLOY_ to `build_and_deploy` +- Click _Build_ + +[Kudos - Richards images](https://github.wdf.sap.corp/D057156) \ No newline at end of file -- 2.34.1