Skip to content

Commit

Permalink
Clean up ci-runner dockerfiles & upgrade nodejs 14.19.1 (#2030)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon authored Apr 25, 2022
1 parent d08eb7b commit 3b65a0a
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 328 deletions.
9 changes: 9 additions & 0 deletions docker/ci/config/build-opensearch-dashboards-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/bash

# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# This script is used as an entrypoint to switch nvm version

source $NVM_DIR/nvm.sh
nvm install $NODE_VERSION
nvm use $NODE_VERSION
Expand Down
32 changes: 32 additions & 0 deletions docker/ci/config/cypress-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# This script is used to build cypress, especially arm64 version
# as there is no arm64 version when you `npm install cypress`.
# The installed version will be fixed to x64 version

# DO NOT ADD -e as there will be compilation failure for some packages, but cypress will be built later
set -x

CPU_NUM=`cat /proc/cpuinfo | grep processor | wc -l`

if [ "$CPU_NUM" -le 4 ]
then
echo "You need a server with more than 4 CPU to succeed the build"
exit 1
fi

cd /tmp
git clone https://github.com/cypress-io/cypress.git cypress
cd cypress
git checkout tags/v$1 -b build-branch-$1
yarn install
yarn binary-build --version "$1"
yarn binary-zip
mv -v cypress.zip /tmp/cypress-$1.zip
exit 0
55 changes: 55 additions & 0 deletions docker/ci/config/jdk-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# Downloads JDK distributions using Eclipse Adoptium project.
# The distributions are extracted to /opt/java/ folder
# with environment variables JAVA${MAJOR_VERSION}_HOME exported and pointing at respective ones.
# JAVA_HOME as well as PATH=$PATH:JAVA_HOME is default to the one with the highest version.

set -eux

ARCH="$(uname -m)"
JDKS=""

case "${ARCH}" in
aarch64|arm64)
# Use "<checksum>@<URL>" format to collect all JDK platform specific distributions
JDKS+="f287cdc2a688c2df247ea0d8bfe2863645b73848e4e5c35b02a8a3d2d6b69551@https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_aarch64_linux_hotspot_8u302b08.tar.gz "
JDKS+="0ba188a2a739733163cd0049344429d2284867e04ca452879be24f3b54320c9a@https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.14_9.tar.gz "
JDKS+="302caf29f73481b2b914ba2b89705036010c65eb9bc8d7712b27d6e9bedf6200@https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.2_8.tar.gz "
;;
amd64|x86_64)
# Use "<checksum>@<URL>" format to collect all JDK platform specific distributions
JDKS+="cc13f274becf9dd5517b6be583632819dfd4dd81e524b5c1b4f406bdaf0e063a@https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz "
JDKS+="1189bee178d11402a690edf3fbba0c9f2ada1d3a36ff78929d81935842ef24a9@https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14_9.tar.gz "
JDKS+="288f34e3ba8a4838605636485d0365ce23e57d5f2f68997ac4c2e4c01967cd48@https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz "
;;
*)
echo "Unsupported arch: ${ARCH}"
exit 1
;;
esac

for jdk in ${JDKS}; do
ESUM=$(echo ${jdk} | cut -d '@' -f1)
BINARY_URL=$(echo ${jdk} | cut -d '@' -f2)
regex="temurin([0-9]+)[-]"
if [[ $jdk =~ $regex ]]; then
MAJOR=${BASH_REMATCH[1]}
curl -LfsSo /tmp/openjdk-${MAJOR}.tar.gz ${BINARY_URL}
echo "${ESUM} */tmp/openjdk-${MAJOR}.tar.gz" | sha256sum -c -
mkdir -p /opt/java/openjdk-${MAJOR}
cd /opt/java/openjdk-${MAJOR}
tar -xf /tmp/openjdk-${MAJOR}.tar.gz --strip-components=1
rm -rf /tmp/openjdk-${MAJOR}.tar.gz
echo "export JAVA${MAJOR}_HOME=/opt/java/openjdk-${MAJOR}" >> /etc/profile.d/java_home.sh
fi
done;

echo "export JAVA_HOME=\$JAVA${MAJOR}_HOME" >> /etc/profile.d/java_home.sh
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile.d/java_home.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ FROM centos:7
# Ensure localedef running correct with root permission
USER 0

# Add AdoptOpenJDK Repo
RUN echo -e "[AdoptOpenJDK]\nname=AdoptOpenJDK\nbaseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/7/\$basearch\nenabled=1\ngpgcheck=1\ngpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public" > /etc/yum.repos.d/adoptopenjdk.repo

# Setup ENV to prevent ASCII data issues with Python3
RUN echo "export LC_ALL=en_US.utf-8" >> /etc/profile.d/python3_ascii.sh && \
echo "export LANG=en_US.utf-8" >> /etc/profile.d/python3_ascii.sh && \
Expand All @@ -27,7 +24,7 @@ RUN echo "export LC_ALL=en_US.utf-8" >> /etc/profile.d/python3_ascii.sh && \
# Add normal dependencies
RUN yum clean all && \
yum update -y && \
yum install -y adoptopenjdk-14-hotspot which curl git gnupg2 tar net-tools procps-ng python3 python3-devel python3-pip
yum install -y which curl git gnupg2 tar net-tools procps-ng python3 python3-devel python3-pip zip unzip

# Create user group
RUN groupadd -g 1000 opensearch && \
Expand All @@ -47,54 +44,9 @@ RUN yum install -y nss xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils
# Add Yarn dependencies
RUN yum groupinstall -y "Development Tools" && yum clean all && rm -rf /var/cache/yum/*

# Downloads JDK-8, JDK-11 and JDK-17 distributions using Eclipse Adoptium project.
# The distributions are extracted to /opt/java/ folder with environment variables JAVA8_HOME,
# JAVA11_HOME and JAVA17_HOME exported and pointing at respective ones.
RUN set -eux; \
ARCH="$(uname -m)"; \
JDKS=""; \
case "${ARCH}" in \
aarch64|arm64) \
# Use "<checksum>@<URL>" format to collect all JDK platform specific distributions
JDKS+="f287cdc2a688c2df247ea0d8bfe2863645b73848e4e5c35b02a8a3d2d6b69551@https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_aarch64_linux_hotspot_8u302b08.tar.gz "; \
JDKS+="105bdc12fcd54c551e8e8ac96bc82412467244c32063689c41cee29ceb7452a2@https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.12_7.tar.gz "; \
JDKS+="e08e6d8c84da28a2c49ccd511f8835c329fbdd8e4faff662c58fa24cca74021d@https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_aarch64_linux_hotspot_17_35.tar.gz "; \
;; \
amd64|x86_64) \
# Use "<checksum>@<URL>" format to collect all JDK platform specific distributions
JDKS+="cc13f274becf9dd5517b6be583632819dfd4dd81e524b5c1b4f406bdaf0e063a@https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.tar.gz "; \
JDKS+="8770f600fc3b89bf331213c7aa21f8eedd9ca5d96036d1cd48cb2748a3dbefd2@https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz "; \
JDKS+="6f1335d9a7855159f982dac557420397be9aa85f3f7bc84e111d25871c02c0c7@https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_linux_hotspot_17_35.tar.gz "; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac; \
for jdk in ${JDKS}; do \
ESUM=$(echo ${jdk} | cut -d '@' -f1); \
BINARY_URL=$(echo ${jdk} | cut -d '@' -f2); \
regex="temurin([0-9]+)[-]"; \
if [[ $jdk =~ $regex ]]; then \
MAJOR=${BASH_REMATCH[1]}; \
curl -LfsSo /tmp/openjdk-${MAJOR}.tar.gz ${BINARY_URL}; \
echo "${ESUM} */tmp/openjdk-${MAJOR}.tar.gz" | sha256sum -c -; \
mkdir -p /opt/java/openjdk-${MAJOR}; \
cd /opt/java/openjdk-${MAJOR}; \
tar -xf /tmp/openjdk-${MAJOR}.tar.gz --strip-components=1; \
rm -rf /tmp/openjdk-${MAJOR}.tar.gz; \
echo "export JAVA${MAJOR}_HOME=/opt/java/openjdk-${MAJOR}" >> /etc/profile.d/java_home.sh; \
fi; \
done;

# Setup Shared Memory
RUN chmod -R 777 /dev/shm

# Set JAVA_HOME and JAVA14_HOME
# AdoptOpenJDK apparently does not add JAVA_HOME after installation
RUN echo "export JAVA_HOME=`dirname $(dirname $(readlink -f $(which javac)))`" >> /etc/profile.d/java_home.sh && \
echo "export JAVA14_HOME=`dirname $(dirname $(readlink -f $(which javac)))`" >> /etc/profile.d/java_home.sh

# Install PKG builder dependencies with rvm
RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - && \
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - && \
Expand Down Expand Up @@ -138,7 +90,7 @@ ENV PATH=/usr/share/opensearch/.gem/gems/fpm-1.14.2/bin:$PATH
# nvm environment variables
ENV NVM_DIR /usr/share/opensearch/.nvm
ENV NODE_VERSION 10.24.1
ARG NODE_VERSION_LIST="10.24.1 14.18.2"
ARG NODE_VERSION_LIST="10.24.1 14.19.1"
COPY --chown=1000:1000 config/build-opensearch-dashboards-entrypoint.sh /usr/share/opensearch
# install nvm
# https://github.com/creationix/nvm#install-script
Expand Down
Loading

0 comments on commit 3b65a0a

Please sign in to comment.