Discourse: Difference between revisions
Leo McArdle (talk | contribs) (Add development setup docs) |
Leo McArdle (talk | contribs) (Added more documentation) |
||
| Line 24: | Line 24: | ||
<pre> | <pre> | ||
git clone https://github.com/discourse/discourse.git | [host]$ git clone https://github.com/discourse/discourse.git -b tests-passed | ||
</pre> | </pre> | ||
| Line 30: | Line 30: | ||
<pre> | <pre> | ||
cd discourse | [host]$ cd discourse | ||
</pre> | </pre> | ||
| Line 36: | Line 36: | ||
<pre> | <pre> | ||
vagrant up | [host]$ vagrant up | ||
</pre> | </pre> | ||
| Line 44: | Line 44: | ||
<pre> | <pre> | ||
vagrant ssh | [host]$ vagrant ssh | ||
</pre> | </pre> | ||
| Line 50: | Line 50: | ||
<pre> | <pre> | ||
cd /vagrant | [vagrant]$ cd /vagrant | ||
</pre> | </pre> | ||
| Line 56: | Line 56: | ||
<pre> | <pre> | ||
bundle install | [vagrant]$ bundle install | ||
</pre> | </pre> | ||
| Line 62: | Line 62: | ||
<pre> | <pre> | ||
bundle exec rake db:migrate | [vagrant]$ bundle exec rake db:migrate | ||
</pre> | </pre> | ||
Create an admin user: | Create an admin user: | ||
<pre> | <pre> | ||
bundle exec rake admin:create | [vagrant]$ bundle exec rake admin:create | ||
</pre> | </pre> | ||
| Line 84: | Line 84: | ||
(replacing <code><username></code> with the admin username) | (replacing <code><username></code> with the admin username) | ||
=== Stopping the development environment === | |||
To stop the server, kill it with <code>^C</code> | |||
Exit the VM and stop it: | |||
<pre> | |||
[vagrant]$ exit | |||
[host]$ vagrant halt | |||
</pre> | |||
=== Updating the development environment === | |||
You should regularly pull in changes from upstream, do this with: | |||
<pre> | |||
[host]$ git pull origin tests-passed | |||
</pre> | |||
After every update, you'll need to update the installed gems and run the db migrations: | |||
<pre> | |||
[host]$ vagrant up | |||
[host]$ vagrant ssh | |||
[vagrant]$ cd /vagrant | |||
[vagrant]$ bundle install | |||
[vagrant]$ bundle exec rake db:migrate | |||
</pre> | |||
=== Using the development environment === | |||
Discourse can now be worked on in your favourite editor, outside of the VM, and the changes will reflect themselves inside: | |||
<pre> | |||
[host]$ cd discourse | |||
[host]$ atom . | |||
</pre> | |||
Modifying the Rails app (changing <code>.rb</code> files) will require you to kill and restart the server: | |||
<pre> | |||
[vagrant]$ ^C | |||
[vagrant]$ bundle exec rails s -b 0.0.0.0 | |||
</pre> | |||
Modifying the Ember app (changing <code>.js</code>, <code>.hbs</code> or <code>.css</code>) files only requires a page refresh. Occasionally the temporary files folder needs to be wiped, so if something isn't working as expected try: | |||
<pre> | |||
[vagrant]$ ^C | |||
[vagrant]$ rm -rf tmp | |||
[vagrant]$ bundle exec rails s -b 0.0.0.0 | |||
</pre> | |||
Most of development work within Mozilla is done on plugins. To keep your code clean we suggest cloning plugins into separate directories, and then linking to them in the <code>discourse/plugins</code> directory. | |||
A method which works for one developer is: | |||
<pre> | |||
[host]$ git clone https://github.com/LeoMcA/discourse-mozillians.git | |||
[host]$ mkdir discourse/plugins/discourse-mozillians | |||
[host]$ sudo mount -o bind ~/Projects/discourse-mozillians ~/Projects/discourse/plugins/discourse-mozillians | |||
</pre> | |||
Revision as of 12:08, 1 November 2016
Discourse is a communication platform "for the next 10 years". It features a clean web interface, mailing list features and much more.
This page contains all the important details about and for the use, setup and development of Discourse within Mozilla.
Current instances
Documentation
Development
Setting up the development environment
The quickest and easiest way to get up and running with hacking on Discourse is using Vagrant, the following steps will download, provision and setup a development virtual machine for you.
Ensure you have Git, VirtualBox and Vagrant installed.
Open a terminal, and clone the Discourse repository with:
[host]$ git clone https://github.com/discourse/discourse.git -b tests-passed
Then enter the project directory:
[host]$ cd discourse
To start downloading, provisioning and booting the VM, run:
[host]$ vagrant up
This will take quite a while, so go grab a hot chocolate.
Once the VM has booted up, you can shell into it with:
[host]$ vagrant ssh
Then enter the project directory, within the VM:
[vagrant]$ cd /vagrant
Install the required gems:
[vagrant]$ bundle install
Run the database migrations:
[vagrant]$ bundle exec rake db:migrate
Create an admin user:
[vagrant]$ bundle exec rake admin:create
And start the rails server:
bundle exec rails s -b 0.0.0.0
After a few seconds rails will start serving pages, and you should be able to access your Discourse instance at: http://localhost:4000
To log in as the admin user, navigate to:
http://localhost:4000/session/<username>/become
(replacing <username> with the admin username)
Stopping the development environment
To stop the server, kill it with ^C
Exit the VM and stop it:
[vagrant]$ exit [host]$ vagrant halt
Updating the development environment
You should regularly pull in changes from upstream, do this with:
[host]$ git pull origin tests-passed
After every update, you'll need to update the installed gems and run the db migrations:
[host]$ vagrant up [host]$ vagrant ssh [vagrant]$ cd /vagrant [vagrant]$ bundle install [vagrant]$ bundle exec rake db:migrate
Using the development environment
Discourse can now be worked on in your favourite editor, outside of the VM, and the changes will reflect themselves inside:
[host]$ cd discourse [host]$ atom .
Modifying the Rails app (changing .rb files) will require you to kill and restart the server:
[vagrant]$ ^C [vagrant]$ bundle exec rails s -b 0.0.0.0
Modifying the Ember app (changing .js, .hbs or .css) files only requires a page refresh. Occasionally the temporary files folder needs to be wiped, so if something isn't working as expected try:
[vagrant]$ ^C [vagrant]$ rm -rf tmp [vagrant]$ bundle exec rails s -b 0.0.0.0
Most of development work within Mozilla is done on plugins. To keep your code clean we suggest cloning plugins into separate directories, and then linking to them in the discourse/plugins directory.
A method which works for one developer is:
[host]$ git clone https://github.com/LeoMcA/discourse-mozillians.git [host]$ mkdir discourse/plugins/discourse-mozillians [host]$ sudo mount -o bind ~/Projects/discourse-mozillians ~/Projects/discourse/plugins/discourse-mozillians