Discourse as Your First Rails App

I just want to emphasise how much I appreciated this post. I’ve tried getting Vagrant up on Windows before (“Unixism” is a great word for it) and the process failed for me in myriad ways.

Aside: since then, I’ve discovered gow (Gnu On Windows), which is a really lightweight and portable library of binaries like ssh, curl, and the basics like ls - it’s a lot more convenient than Cygwin. Cygwin can be agonising when you have to deal with Ruby gems. It’s also a smidgeon more convenient than Git Bash in quite a lot of places.

Anyway, thanks so much for making this process a bit clearer. I can’t wait to have a look around Discourse - this is my first post, and I’m astounded by how perfectly considered the UI design is.

2 Likes

Here is a quick and dirty translation of Getting Started for Debian/Ubuntu users if you want to toss it in a script or something:

  1. sudo apt-get install git virtualbox nfs-common nfs-kernel-server
  2. wget http://files.vagrantup.com/packages/64e360814c3ad960d810456add977fd4c7d47ce6/vagrant_x86_64.deb
  3. sudo dpkg -i vagrant_x86_64.deb
  4. Open a terminal
  5. Clone the project: git clone git@github.com:discourse/discourse.git
  6. Enter the project directory: cd discourse

Then continue on with the rest of the instructions … (I’m getting an error with the NFS client thing, but that should work, I’m investigating that and will update this when I find the cause.)

4 Likes

I found you also need to add nfs-kernel-server to the list of packages to apt-get install. That got past all my NFS related errors.

2 Likes

A quick note to say that I was getting this error following the instructions on OS X:

[default] Mounting NFS shared folders…

The following SSH command
responded with a non-zero exit status. Vagrant assumes that this means
the command failed!

mount -o vers=3 192.168.10.1:’/path_to/folder’
/vagrant

Fix was very simple, simply make a directory called “vagrant” in the root of the drive you’re running the VM.

Macbook-Air:/ Sina$ sudo mkdir vagrant

Hope that helps someone getting started …

1 Like

To add to your reply to @ndc, they just recently released a way to add a new provider, so it is possible to get it going on hyper-v if someone was willing to do the leg-work for vagarent. http://docs.vagrantup.com/v2/plugins/providers.html

I’m not familiar enough with vagrant to know if its something i’m going to be looking into or not, but I am interested in automating deployments to various VMs. Thanks for pointing it out.

With windows 8 coming with hyper-v as an install option out of box, it sounds like a no-brainer. Also, the free version of hyper-v 2012 is excellent. I just set up a cluster of 3 machines in my basement and have been using no shared state live-migration to offload working servers that I set up on my windows-8 box onto the cluster. its fantastic.

1 Like

thx, had the same problem! maybe @Hanzo could add that to the blog post?

1 Like

Thx, awesome writeup, had it running locally in about an hour.

I searched for hints on Heroku deployment but didn’t find anything definite. Do I simply follow https://devcenter.heroku.com/articles/rails3?

You didn’t look at discourse/docs at master · discourse/discourse · GitHub ?

I got many hits by searching here for “heroku”

Sorry, my bad, searched here on meta only. Yes, many hits, but not what I was hoping for.

For anybody else looking for this: the Heroku step-by-step guide is of course in the docs at https://github.com/discourse/discourse/blob/master/docs/HEROKU.md

A reminder/pointer to the docs would maybe helpful as an ending to the post?

That blog post isn’t about deployment. It’s about getting the site running on your local box for development.

Okay, I want to help with Discourse, but I’ve never did anything in ruby at all and I’m a chicken, so I will go to this cool ruby workshop I found in my city where we all hang out to learn ruby together. Once I’m done and feel ready, I’ll start doing things for the project and I believe this to be the best place to let you all know. Also, what about native linux users? You feel we are strong and independent and will figure things out on our own? Or have we been forgotten?

Vagrant works in Linux, instructions for Ubuntu were posted above.

Awesome, thanks. I didn’t see that post :slight_smile:

@Hanzo That would describe me 100%. That is why I am very interested in looking at Discourse and the article is very helpful in setting up a dev environment.

So thanks for writing it!

1 Like

And what do I then do once I create the /vagrant folder? I can now ssh into the VM but, inside the VM, the vagrant folder is empty.

How can I then mount the NFS share?

Thanks!

I finally got discourse running locally. I am running OSX Mtn Lion. I kept running into vagrant errors and db errors. So I just uninstalled everything (via the included uninstall tools for Vagrant and VirtualBox). Then I installed the exact versions of each that are mentioned in the instructions from the blog post. I didn’t get the newer versions of either Vagrant or VirtualBox.

VirtualBox: “As of this writing, 4.2.10 is the latest and works for us.”
Vagrant: “you’ll need Vagrant 1.1.2 or higher” (don’t go higher)

Finally, everything worked.

Using the shared folder /vagrant will provide really low performance.

If you want decent performance, you will need to do the following:

# create an alias to synchronize the code from the shared folder to a local folder
alias sin="rsync -a --delete /vagrant ~"
# actually synchronize (can take a minute for the first run)
sin
# switch to the local folder
cd ~/vagrant
# standard procedure to update, migrate and launch the application
bundle install
bundle exec rake db:migrate
bundle exec rails s

Enjoy :wink:

9 Likes

And for anyone who wants to run the unit / spec tests on the vagrant image:

bundle exec rake db:migrate
bundle exec rake db:test:prepare
redis-cli flushall
bundle exec rspec
1 Like

This was pretty painless on the mac, I see why you would want to use vagrant on windows and I guess it removes any env issues on the mac as well? I ask because I the only time I set up a VM is to test IE on my MBP
Anyways set up was cooll, thanks for the fun

hmm, nothing is showing up at 0.0.0.0:3000
getting no errors, am I missing something here?