gitlab-build-images/scripts/install-node
Lukas Eipert 5380948868
Ensure that package managers clean up
Every package manager should clean up after themselves in order to keep
docker layers neat and tiny:

apt (Debian/Ubuntu package manager):

 - unneeded dependencies are cleared (autoremove)
 - caches are cleaned (clean)
 - package lists are deleted

yum (CentOS package manager),
zypper (OpenSuse package manager)

 - should clear caches after installing dependencies

pip (Python package manager),
apk (Alpine package manager)

 - should use no cache for installing dependencies
2018-10-04 23:29:51 +02:00

21 lines
665 B
Bash
Executable file

#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
NODE_INSTALL_VERSION=${1:-7.x}
YARN_INSTALL_VERSION=${2:-0.27.5-1}
# Map MAJOR.MINOR.patch -> MAJOR.x
NODE_INSTALL_VERSION=`echo $NODE_INSTALL_VERSION | sed -r -e "s/([0-9]+)\.[0-9]+.*/\1\.x/g"`
# add official debian repos for node and yarn
curl -sS -L https://deb.nodesource.com/setup_${NODE_INSTALL_VERSION} | 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
apt-get install -y nodejs yarn=$YARN_INSTALL_VERSION
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*