Skip to content

Instantly share code, notes, and snippets.

@ocindev
Last active December 12, 2021 10:32
Show Gist options
  • Save ocindev/cbaa98e60fda673ac60f11b05a8fd7f0 to your computer and use it in GitHub Desktop.
Save ocindev/cbaa98e60fda673ac60f11b05a8fd7f0 to your computer and use it in GitHub Desktop.
Convenient script to setup a WSL dev environment with Docker, sdkman.io, Maven, AdoptOpenJDK 1.8, NPM and Node.js
# Replace with your windows username
win_user=<replace>
# Update the apt package list.
sudo apt-get update -y
# Install Docker's package dependencies.
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# Download and add Docker's official public PGP key.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Verify the fingerprint.
sudo apt-key fingerprint 0EBFCD88
# Add the `stable` channel's Docker upstream repository.
#
# If you want to live on the edge, you can change "stable" below to "test" or
# "nightly". I highly recommend sticking with stable!
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Update the apt package list (for the new apt repo).
sudo apt-get update -y
# Install the latest version of Docker CE.
sudo apt-get install -y docker-ce
# Allow your user to access the Docker CLI without needing root access.
sudo usermod -aG docker $USER
# Install Python and PIP.
sudo apt-get install -y python python-pip
# Install Docker Compose into your user's home directory.
pip install --user docker-compose
# Allow Docker Client on WSL to access Docker Host running on Windows.
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc
# Copy Windows ssh key to ubuntu filesystem
cp -r /mnt/c/Users/$win_user/.ssh ~/.ssh
# Fix access rights on ssh key
chmod 600 ~/.ssh/id_rsa
# Install keychain manager to avoid entering ssh key secret every time we use ssh communication
sudo apt install keychain -y
# Evaluate keychain on bash startup
echo "eval ``keychain --eval --agents ssh id_rsa" >> ~/.bashrc && source ~/.bashrc
# Mount Windows C disk under root path instead of /mnt/c
sudo echo -e "[automount]\nenabled=true\nroot=/\noptions=\"metadata,umask=22,fmask=11\"\n" >> /etc/wsl.conf
# Install unzip and zip for sdkman
sudo apt-get -y install unzip zip
# Install sdkman.io
curl -s "https://get.sdkman.io" | bash
# Reload bash with new env
source ~/.sdkman/bin/sdkman-init.sh
# Install maven via sdkman
sdk install maven
# Install java 8 AdoptOpenJDK via sdkman
sdk install java 8.0.242.hs-adpt
# Use Node Version Manager script to install and manage npm and node versions
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
# Reload bash
source ~/.bashrc
# Install NPM and Node.js
nvm install node
# Install Development tools to build native addons
sudo apt-get install -y gcc g++ make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment