Discourse: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:


== Development ==
== Development ==
Development documentation can be found at [[Discourse/Documentation/Development|the Discourse development Wiki page.]]


=== Setting up the development environment ===
== Deployment ==
 
Documentation about how these sites are deployed and maintained can be found at [[Community Ops/Discourse|the Community Ops Discourse wiki page]]
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:
 
<pre>
[host]$ git clone https://github.com/discourse/discourse.git -b tests-passed
</pre>
 
Then enter the project directory:
 
<pre>
[host]$ cd discourse
</pre>
 
To start downloading, provisioning and booting the VM, run:
 
<pre>
[host]$ vagrant up
</pre>
 
This will take quite a while, so go grab a hot chocolate.
 
Once the VM has booted up, you can shell into it with:
 
<pre>
[host]$ vagrant ssh
</pre>
 
Then enter the project directory, within the VM:
 
<pre>
[vagrant]$ cd /vagrant
</pre>
 
Install the required gems:
 
<pre>
[vagrant]$ bundle install
</pre>
 
Run the database migrations:
 
<pre>
[vagrant]$ bundle exec rake db:migrate
</pre>
 
Create an admin user:
<pre>
[vagrant]$ bundle exec rake admin:create
</pre>
 
And start the rails server:
<pre>
bundle exec rails s -b 0.0.0.0
</pre>
 
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:
 
<pre>
http://localhost:4000/session/<username>/become
</pre>
 
(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>
 
Edits can then be made in the <code>discourse-mozillians</code> directory, which are reflected in the <code>discourse/plugins/discourse-mozillians</code> directory, and then in the VM.

Revision as of 17:28, 1 November 2016

Discourse

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

Development documentation can be found at the Discourse development Wiki page.

Deployment

Documentation about how these sites are deployed and maintained can be found at the Community Ops Discourse wiki page