# --------------------
# Installing Ruby using 'ruby version manager'
# --------------------
# see: https://gorails.com/deploy/ubuntu/24.04
# ---
# 0. Install pre-requisites
# ---
#apt-get install -y apt-transport-https ca-certificates curl gnupg
apt-get install git-core \
curl \
zlib1g-dev \
build-essential \
libssl-dev \
libreadline-dev \
libyaml-dev \
libsqlite3-dev sqlite3 \
libxml2-dev \
libxslt1-dev \
libcurl4-openssl-dev \
software-properties-common \
libffi-dev \
dirmngr \
gnupg apt-transport-https ca-certificates \
redis-server redis-tools
# ---
# 1 Install node.js
# ---
# seei also : https://git.oopen.de/install/node.js.git
NODE_VERSION="20.x"
# Download and import the Nodesource GPG key
#
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null
# N|solid Config
echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
# Nodejs Config
echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
apt install nodejs
# ---
# 2. Install yarn
# Download and import Yarn GPG key
#
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/yarn.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list > /dev/null
# Nodejs Yarn
echo "Package: yarn" | tee /etc/apt/preferences.d/yarn > /dev/null
echo "Pin: origin dl.yarnpkg.com" | tee -a /etc/apt/preferences.d/yarn > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/yarn > /dev/null
apt install yarn
# ---
# 3. Install ruby using rbenv (Ruby version mmanager)
# ---
RUBY_VERSION=3.2.2
# Next we're going to install Ruby using a Ruby version mmanager called rbenv.
# It is the easiest and simplest option, plus it comes with some handy plugins
# to let us easily manage environment variables in production.
#
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
git clone https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars
#exec $SHELL
rbenv install ${RUBY_VERSION}
rbenv global ${RUBY_VERSION}
# Test ruby version
#
ruby -v
# ---
# 4. Install Bundler
# ---
# This installs the latest Bundler, currently 2.x.
#
# Note:
#
# For older apps that require Bundler 1.x, you can install it as well:
#
# gem install bundler -v 1.17.3
#
# but we install latest Bundler
#
gem install bundler
# Test version of bundler
#
bundle -v