Use npm repo instead of apt on Yarn install

Co-authored-by: Lukas 'Eipi' Eipert <leipert@gitlab.com>
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
This commit is contained in:
Takuya Noguchi 2021-04-21 02:49:33 +00:00
parent 351ef2e34a
commit e29a606bbc
4 changed files with 10 additions and 11 deletions

View file

@ -133,10 +133,10 @@ function print_node_args() {
function print_yarn_args() {
case "$1" in
1.12) YARN_INSTALL_VERSION=1.12.3-1 ;;
1.16) YARN_INSTALL_VERSION=1.16.0-1 ;;
1.21) YARN_INSTALL_VERSION=1.21.1-1 ;;
1.22) YARN_INSTALL_VERSION=1.22.5-1 ;;
1.12) YARN_INSTALL_VERSION=1.12.3 ;;
1.16) YARN_INSTALL_VERSION=1.16.0 ;;
1.21) YARN_INSTALL_VERSION=1.21.1 ;;
1.22) YARN_INSTALL_VERSION=1.22.10 ;;
*) echo "Unknown yarn version $1"; exit 1;
esac
printf -- "--build-arg YARN_INSTALL_VERSION=%s " "$YARN_INSTALL_VERSION"

View file

@ -3,15 +3,13 @@ set -xeuo pipefail
IFS=$'\n\t'
NODE_INSTALL_VERSION=${1:-14.16.0}
YARN_INSTALL_VERSION=${2:-1.21.1-1}
YARN_INSTALL_VERSION=${2:-1.22.10}
# Map MAJOR.MINOR.patch -> MAJOR.x
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
curl -sS -L https://deb.nodesource.com/setup_${NODE_MAJOR} | bash -
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
apt-get update
@ -20,7 +18,8 @@ curl -s -O "https://deb.nodesource.com/node_$NODE_MAJOR/pool/main/n/nodejs/$NODE
dpkg -i "$NODE_FILE_NAME"
rm -f "$NODE_FILE_NAME"
apt-get install -y yarn=$YARN_INSTALL_VERSION
npm install --global yarn@${YARN_INSTALL_VERSION}
npm cache clean --force
apt-get autoremove -yq
apt-get clean -yqq

View file

@ -27,7 +27,7 @@ apt-get install -yq --no-install-recommends imagemagick
# Install node & yarn
NODE_INSTALL_VERSION=12.4.0
YARN_INSTALL_VERSION=1.21.1-1
YARN_INSTALL_VERSION=1.22.10
/scripts/install-node $NODE_INSTALL_VERSION $YARN_INSTALL_VERSION && node --version && yarn --version
# Install yamllint