Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to install Discourse 2.4+ on Dokku (2019)


How to install Discourse 2.4+ on Dokku (2019)

Discourse is very clear that they do not support anything else than their official install instructions, which more or less requires a dedicated server.

However, being a docker image, it should be possible to install it on dokku.

These instructions are based on, and updated to work with current Discourse + Dokku.

Bootstrapping Discourse

Discourse has a repository dedicated to bootstrapping a docker image. We'll follow some of their instructions, but will adapt them to our needs.

On the server, clone the Official Discourse Docker Image:

git clone /var/discourse
cd /var/discourse

Instead of using the setup tool, we'll do the configuration manually. Copy the default standalone configuration and edit it:

cp samples/standalone.yml containers/app.yml
nano containers/app.yml

You'll need to at least set the following (SMTP is mandatory for Discourse to work):

  ## Required. Discourse will not work with a bare IP number.

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example ','

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

Do not set the Let's Encrypt email, as we'll manage SSL through dokku.

Save the config file and bootstrap the image:

./launcher bootstrap app

If successful, you should see an image named local_discourse/app when you run the following command:

docker images

Configuring Dokku

Now you can setup and configure the app with Dokku.

dokku apps:create discourse
dokku domains:set discourse

dokku proxy:ports-add discourse http:80:80
dokku proxy:ports-remove discourse http:80:5000

Docker run

The Discourse launcher actually runs a custom docker run command, with a whole lot of arguments. We'll replicate it using dokku features.

Get the command used to start the Discourse instance:

./launcher start-cmd app

Replace the values with your output of the prior command, splitting by type of arguments:

  • Discard the -p port:port arguments

  • Join all the -e ENV vars and set them like this:

  • Set both -v volumes:

    dokku storage:mount discourse /var/discourse/shared/standalone:/shared
    dokku storage:mount discourse /var/discourse/shared/standalone/log/var-log:/var/log
  • Set the following Docker options (--entrypoint is especially important):

    dokku docker-options:add discourse run,deploy "--entrypoint /sbin/boot"
    dokku docker-options:add discourse run,deploy "--hostname dokku-discourse"
    dokku docker-options:add discourse run,deploy "--shm-size=512m"
    dokku docker-options:add discourse run,deploy "--mac-address aa:bb:cc:dd:ee:ff"
  • Set the restart policy --restart (this is probably optional):

    dokku ps:set-restart-policy discourse always
  • You should ignore other options like -t

Deploy to dokku

To make it easier, we'll deploy using docker tags:

docker tag local_discourse/app:latest dokku/discourse:latest
dokku tags:deploy discourse latest

The app should deploy and then start.

Set up SSL

dokku config:set --no-restart discourse
dokku letsencrypt discourse

Finish setup

First thing: skip wizard and enable force_https from admin dashboard (make sure to have setup letsencrypt and that https works fine). Then restart the wizard if you want.

Then follow the next steps to register an admin account.

You can also add plugins and more.

How to update Discourse

Based on default update instructions, with a twist because of dokku:

dokku ps:stop discourse
cd /var/discourse/
./launcher bootstrap app
# wait for it...
docker tag local_discourse/app:latest dokku/discourse:latest
dokku tags:deploy discourse latest


Make sure to backup contents in /shared, cf.

## The Docker container is stateless; all data is stored in /shared
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared



This comment has been minimized.

Copy link

@badsyntax badsyntax commented Nov 9, 2020

I've created a plugin to make this easier:


This comment has been minimized.

Copy link
Owner Author

@julienma julienma commented Nov 9, 2020

@badsyntax noice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment