Merge branch 'leipert-pin-node' into 'master'

Pin node versions

See merge request gitlab-org/gitlab-build-images!207
This commit is contained in:
Mike Greiling 2019-07-09 01:51:15 +00:00
commit 84bff20408
3 changed files with 15 additions and 9 deletions

View file

@ -5,7 +5,7 @@ ADD /scripts/ /scripts/
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y git \ && apt-get install -y git \
&& /scripts/install-node 12.x 1.16.0-1 \ && /scripts/install-node 12.4.0 1.16.0-1 \
&& yarn global add alex@7 \ && yarn global add alex@7 \
&& yarn cache clean \ && yarn cache clean \
&& apt-get autoremove -yq \ && apt-get autoremove -yq \

View file

@ -79,9 +79,9 @@ function print_git_args() {
function print_node_args() { function print_node_args() {
case "$1" in case "$1" in
8.x) NODE_INSTALL_VERSION=8.x ;; 8.x) NODE_INSTALL_VERSION=8.16.0 ;;
10.x) NODE_INSTALL_VERSION=10.x ;; 10.x) NODE_INSTALL_VERSION=10.16.0 ;;
12.x) NODE_INSTALL_VERSION=12.x ;; 12.x) NODE_INSTALL_VERSION=12.4.0 ;;
*) echo "Unknown node version $1"; exit 1; *) echo "Unknown node version $1"; exit 1;
esac esac
printf -- "--build-arg NODE_INSTALL_VERSION=%s " "$NODE_INSTALL_VERSION" printf -- "--build-arg NODE_INSTALL_VERSION=%s " "$NODE_INSTALL_VERSION"

View file

@ -2,19 +2,25 @@
set -xeuo pipefail set -xeuo pipefail
IFS=$'\n\t' IFS=$'\n\t'
NODE_INSTALL_VERSION=${1:-7.x} NODE_INSTALL_VERSION=${1:-12.4.0}
YARN_INSTALL_VERSION=${2:-0.27.5-1} YARN_INSTALL_VERSION=${2:-1.16.0-1}
# Map MAJOR.MINOR.patch -> MAJOR.x # Map MAJOR.MINOR.patch -> MAJOR.x
NODE_INSTALL_VERSION=`echo $NODE_INSTALL_VERSION | sed -r -e "s/([0-9]+)\.[0-9]+.*/\1\.x/g"` NODE_MAJOR=`echo $NODE_INSTALL_VERSION | sed -r -e "s/([0-9]+)\.[0-9]+.*/\1\.x/g"`
# add official debian repos for node and yarn # add official debian repos for node and yarn
curl -sS -L https://deb.nodesource.com/setup_${NODE_INSTALL_VERSION} | bash - curl -sS -L https://deb.nodesource.com/setup_${NODE_MAJOR} | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update apt-get update
apt-get install -y nodejs yarn=$YARN_INSTALL_VERSION
NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-1nodesource1_amd64.deb"
curl -s -O "https://deb.nodesource.com/node_$NODE_MAJOR/pool/main/n/nodejs/$NODE_FILE_NAME"
dpkg -i "$NODE_FILE_NAME"
rm -f "$NODE_FILE_NAME"
apt-get install -y yarn=$YARN_INSTALL_VERSION
apt-get autoremove -yq apt-get autoremove -yq
apt-get clean -yqq apt-get clean -yqq