From development to production howto


For evelopment I’m using the following installation: Beginners Guide to Install Discourse on Ubuntu for Development

Since I plan to do some changes to the code (css, ruby and db), how can I install my changes for production?
Do I have to build a docker image? or, can I use the existing image and update the code in the image after installation?
and for either option - how do I do that?

(cpradio) #2

Using plugins. That is the only support way of altering code on a Docker instance.


But I am altering the code in a development environment. Not in a docker instance.
I use Docker only for production (since I understood this is the only way for production discourse)

(cpradio) #5

You don’t want to physically alter the code, you need to leave the code as is, and utilize plugins to implement your changes.


ok, so do I have to use the development environment for that? Is it possible to directly develop plugins for docker without the development environment?

(cpradio) #7

You can, it takes a lot more time and more trial and error. As you have to have a github repo for your plugin, push the changes to your github repo and then have Discourse upgrade to that version.

For development, you’d still have a repo, but you can utilize your local changes before pushing them to github by cloning your repo in /discourse/plugins/ folder and making your adjustments as needed, then when you are happy, you commit them and push them to github for your docker install to utilize.


One more question then, do I have to use Github for plugins?

(cpradio) #9

You can probably use bitbucket, but you have to have a repo of it somewhere for Discourse to download the plugin code from.

(Kim Kern) #10

If a remote repo wasn’t an option, wouldn’t it also be possible to include a local plugin folder from the host system as a volume and then copy it into the plugins folder like this:

  - volume:
      host: /var/discourse/shared/plugins
      guest: /plugins


- exec: echo "Beginning of custom commands"
- exec: cp -R /plugins/my-plugin $host/plugins

(Michael Howell) #11

Yeah, you can use a local plugin folder as a volume.

But if you make a change to your plugin and it breaks more things than it fixes, you want to be able to revert the change. You also want to have a backup of your plugin’s code, since the backup system in Discourse itself doesn’t include it (and whole-machine backups are enormous, and thus infrequently taken and slow to restore). You also want to keep track of when and why the plugin’s code changes. You also want to be synchronizing the plugin’s code between a development instance and the production instance.

Using a code repository like a normal person fixes all of these problems.