Here are some rough notes on how I went about install Discourse on Bash for Windows:
Install required packages
Mostly a cut-and-paste job from our docker base image.
curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" | sudo tee /etc/apt/sources.list.d/postgres.list
sudo apt-get update
sudo apt-get install build-essential git build-essential git wget \
libxslt1-dev libcurl4-openssl-dev \
libssl-dev libyaml-dev libtool \
libxml2-dev gawk \
postgresql-client-9.5 libpq-dev libreadline-dev \
language-pack-en \
psmisc whois redis-server \
advancecomp jhead jpegoptim libjpeg-turbo-progs optipng libjemalloc-dev imagemagick
Installing rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exit shell and start again so env is there.
Install ruby
rbenv install 2.3.1
echo 2.3.1 >> ~/.rbenv/version
Make this will take a while cause the filesystem is very slow.
Install Postgres on Windows
https://www.postgresql.org/download/windows/
This is required cause installing postgres is not yet supported.
Install Discourse
git clone https://github.com/discourse/discourse.git
gem install bundler
cd discourse
bundle install
# correct bundler permissions per http://stackoverflow.com/questions/37211007/installing-rails-on-ubuntu-bash-windows-10
chmod -R +t ~/.bundle/cache
bundle install
Hack database config
Edit config/database.yml
:
Add the following into test and development sections:
host: localhost
username: postgres
password: YOURPWD
port: 5432
Start up redis
redis-server --bind 0.0.0.0
Migrate Discourse
bin/rake db:create db:migrate
Discourse now runs! hooray
At the end of this process Discourse running on Windows without ANY VM installed. This is quite impressive.
bundle exec puma
The good news!
Discourse runs fine, its a little bit fiddly but all the gems install and the test suite runs.
Once booted up Discourse is quite fast and usable.
The bad news!
The filesystem mapping technology keeps the original files in an NTFS partition and performs internal mapping, pretending this filesystem is actually a Linux native one. Unfortunately NTFS + mapping overhead means that it is much slower than using ext4fs directly or some other native solution.
The effect of this in real terms is:
- Running our test suite is slower
Bash on Ubuntu on Windows takes 8:20 to run the test suite. My ubuntu VM takes 6:15. Same hardware.
- Installing ruby / gems and so on is a lot slower
Ruby has lots of little files, I did not time it but it feels at least twice slower to compile ruby from source.
- Booting Discourse takes more than twice longer:
# Linux VM
sam@ubuntu discourse % time bin/rails r "puts 'hi'"
hi
2.54s user
0.50s system
99% cpu
3.059 total
# Bash on Ubuntu on Windows
sam@SAM-PC:~/discourse$ time bin/rails r "puts 'hi'"
hi
real 0m7.123s
user 0m3.063s
sys 0m4.000s
7.12secs VS 3.05secs
This means that starting up a dev web server and opening up a rails console take much longer.
This is a huge issue, it is big enough for me to recommend against this setup for now.
There is an open ticket that once resolved will allow bash on Windows to run native filesystems, once that is implemented we should revisit these results:
https://github.com/Microsoft/BashOnWindows/issues/131
Note: All tests were done on the beta version of Bash on Ubuntu on Windows that is bundled with Windows 10 anniversary edition (made public on 2nd of August 2016)