Skip to content

Instantly share code, notes, and snippets.

@dominicsayers
Last active February 9, 2020 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dominicsayers/a99c0b938f94f4562090a4005c10848d to your computer and use it in GitHub Desktop.
Save dominicsayers/a99c0b938f94f4562090a4005c10848d to your computer and use it in GitHub Desktop.
Setting up Windows Services for Linux and Docker for Windows for Ruby on Rails development

Setting up Windows Services for Linux (WSL) and Docker for Windows for Ruby on Rails development

Prerequisites

On your Windows 10 development machine you should have installed

  1. Windows Services for Linux and a Debian-based app like Ubuntu.
  2. putty
  3. Docker for Windows (and I use Kitematic because I'm a Docker n00b)

putty should be configured to supply your private key to authenticate with a server.

SSH server

sudo ssh-keygen -A # or it moans that the server keys aren't there
sudo service ssh start
mkdir ~/.ssh && chmod 700 ~/.ssh
curl -o ~/.ssh/authorized_keys https://dominicsayers.keybase.pub/keys/id_rsa.pub && chmod 600 ~/.ssh/*

You should now be able to connect to localhost using putty. From this point on it's easier to use putty than the WSL console (in my opinion).

Bash

curl -o ~/.bashrc_extras https://gist.githubusercontent.com/dominicsayers/0f8e6fe6621714c92764/raw/218e5e1ac905402290938852b6ef5e6b03832c8d/2)%2520.bashrc
echo -e "\nif [ -f $HOME/.bashrc_extras ]; then\n  source $HOME/.bashrc_extras\nfi" >> ~/.bashrc
source ~/.bashrc

ZSH

curl -o ~/.zshrc_extras https://gist.githubusercontent.com/dominicsayers/0f8e6fe6621714c92764/raw/218e5e1ac905402290938852b6ef5e6b03832c8d/1)%2520.zshrc
echo -e "\nif [ -f $HOME/.zshrc_extras ]; then\n  source $HOME/.zshrc_extras\nfi" >> ~/.zshrc
source ~/.zshrc

RVM

Using instructions from rvm.io

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source /home/build/.rvm/scripts/rvm
type rvm | head -n 1
rvm autolibs enable
rvm requirements
echo rvm_autoupdate_flag=2 >> ~/.rvmrc
rvm rvmrc warning ignore allGemfile

Keybase

I keep a copy of my private keys in Keybase so we'll install this first.

Instructions copied from Keybase site

curl -O https://prerelease.keybase.io/keybase_amd64.deb
# if you see an error about missing `libappindicator1`
# from the next command, you can ignore it, as the
# subsequent command corrects it
sudo dpkg -i keybase_amd64.deb
sudo apt-get install -f
run_keybase

Then do a keybase login - consult the documentation to find out how to register an account and provision a device if you need to. What we're looking for is to be able to do this:

keybase fs ls -a -l /keybase/public/dominicsayers/keys

Git

git config --global user.email "dominic@sayers.cc"
git config --global user.name "Dominic Sayers"
git config --global pull.rebase true
git config --global rebase.autosquash true
keybase fs read /keybase/private/dominicsayers/keys/id_rsa > ~/.ssh/id_rsa && chmod 600 ~/.ssh/*
ssh -vT git@github.com

App prerequisites

The app I'll be working on has some prerequisites. Yours may too. Lets install them now.

# To successfully install the `pg` gem we need the Postgres client
sudo apt-get install libpq-dev postgresql-client
# We need a Javascript runtime
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

For my tests to run successfully I now need to download a postgresql Docker image, configure it with a port and password (or no password) and set it running.

Development environment

mkdir -p Development/dominicsayers
dev
git clone git@github.com:dominicsayers/rails-template.git
cd rails-template
git checkout initial-scaffolding
cd . # Should prompt to install a ruby
cd . # again. Now it should create a gemset
gem update --system
gem install bundler
bin/bundle
bin/rubocop
bin/rails db:setup RAILS_ENV=test # Probably need to make a `.env.test.local` or `config/database.yml` at this point
bin/rspec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment