Created
March 22, 2023 09:28
-
-
Save timlrx/680a44f21f06831fbdae550fb43ff0fd to your computer and use it in GitHub Desktop.
Shell script to install python (via pyenv), node (via nvm) and docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
sudo apt-get update -y | |
# Basic packages | |
sudo apt-get install -y \ | |
git \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
software-properties-common \ | |
lsb-release \ | |
dirmngr \ | |
unzip \ | |
# Needed for pyenv | |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev \ | |
libbz2-dev libreadline-dev libsqlite3-dev curl \ | |
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | |
# Add docker ubuntu repositories | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
# Install docker | |
sudo apt-get update -y | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin | |
# Manage Docker as a non-root user | |
sudo groupadd -f docker | |
sudo usermod -aG docker $USER | |
# Install python | |
if [ ! -r ~/.pyenv/ ] | |
then | |
curl https://pyenv.run | bash | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(pyenv init -)"' >> ~/.bashrc | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile | |
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile | |
echo 'eval "$(pyenv init -)"' >> ~/.profile | |
pyenv install 3.10 | |
pyenv global 3.10 | |
fi | |
# Install nvm | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | |
# Start using nvm now | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
nvm install 18 | |
nvm use 18 | |
# User should run `newgrp docker` to switch to the docker group | |
newgrp docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment