We launched a Discourse forum for the Inventables Community last month. It is a real hit with our customers and is quickly gaining popularity. The best part about Discourse (at least for developers) is that it is open source and built on a familiar stack of technologies (Rails, Postgres, Redis). So let’s start hacking on it!
Setting it up locally wasn’t as straightforward as I thought it would be. There are several different guides up, and it is not clear exactly which one you should use for production vs. development. After a few hours of trying to get it set up directly on my Mac (bad idea), I tried the guide to set it up on Vagrant.
Vagrant works together with VirtualBox to create a simple way to provision a development environment in code. You create a Vagrantfile that specifies exactly what your environment needs.
First, install VirtualBox and install Vagrant.
Then a few commands to get it started:
git clone <DISCOURSE_REPO>
cd discourse
# setup vagrant discourse box
# this may take some time (a few minutes?)
vagrant up
# enter vagrant box
vagrant ssh
bundle install
bundle exec rake db:migrate
# start the server
bundle exec rails s
# now discourse is accessible at localhost:4000
My first question about this setup was why port 4000?
The Vagrantfile
source shows why:
...
config.vm.network :forwarded_port, guest: 3000, host: 4000
config.vm.network :forwarded_port, guest: 1080, host: 4080 # Mailcatcher
...
Vagrant forwards to standard rails port in the virtual box (3000) out back to us on port 4000. It does the same thing for the Mailcatcher port.