Deploying and Maintaining Discourse on Digital Ocean (2020)

Requirements for deployment

DNS provider

there a tons out there (recommend 1 namecheap)

  • choose discourse url (for this example we will use discuss.aves.io)

SMTP transactional email provider

there are tons out there (recommend 1 SendInBlue)

  • you will get credentials for smtp sever url, port, login, password

Digital Ocean Account

great low cost deployment option and what the tutorial is centered around

Admin Email Address

whatever email address you want the default discourse admin to be. I highly recommend using an email alias or email group (prefer later) – since you don't want your service to depend on a single person's email!

command line experience

some familiarity with the command line is required (but not ssh)

Installation

Configure Droplet

Login to DigitalOcean Login (you may already be logged in)

Visit Digital Ocean Marketplace (One Click Install) - Discourse

Click the "Create Discourse Droplet"

/images/20200523_105537.png

Choose a Droplet Size

1 CPU and 2 GB is plenty for discourse. 1 GB of RAM is not enough for discourse upgrades.

/images/20200526_215151.png

Choose a Droplet Location

For droplet location choose the closest location to your users.

/images/20200526_215445.png

Select Droplet Access Method

You are given the option for password or ssh based access. It is highly recommended to use ssh. If you use password based access make sure it is a long password.

/images/20200526_215745.png

Label and Name Resources

When deploying resources in the cloud it is especially important to name and label resources. Typical tags to include are creation date, project, development, production. More is better.

/images/20200526_220006.png

Finally Click "Create Droplet"

Identify the IP Address of the Resulting Droplet

/images/20200526_220453.png

In the case of this example the IP address is 157.245.247.126.

Point DNS A record at Droplet

Using the DNS Provider that you have chosen with a controlled domain. Point an A record at the IP Address. Every provider will have support for this type of record. In the figure below we show setting the DNS name via cloudflare.

/images/20200527_084220.png

Configuring Discourse

Use Console to Login to Droplet

If you have configured ssh key access you will have to use ssh to connect with your public/private key pair. If you chose a master password option you may use the console button to login with username root with master password that you specified when creating the droplet.

/images/20200526_221656.png

Answer Discourse Installation Prompt

/images/20200526_221908.png

Enter your:

hostname

url that discourse site is accessiable from discuss.aves.io for this example

admin email address

email address that discourse uses for inital login

transactional email settings

smtp address, smtp port, smtp login, smtp password

/images/20200527_091249.png

Installation should take around 5 minutes and you should be able to visit your discourse server and do administrative setup and discourse customization.

Administrative Discourse Setup

Visit Discourse Website

The first time you visit your discourse site you will see the following landing page. This page will continue to persist until an administrator has successfully logged into the site.

/images/20200527_092831.png

Once you click register you will need to register the username associated with the admin email setup previously in configuring discourse. Note that this is the master password so keep it secure.

Click Activation Link with Admin Email

Once you have entered your username and password you will recieve an email at your admin email address similar to the figure below.

/images/20200527_093428.png

Welcome to Discourse and the Customization of Discourse Begins

Discourse is extremely customizable thus this tutorial cannot go into depth on discourse and we suggest the reading discourse's discourse site. These initial settings will adjust the look and feel of your site to make it feel personal to your audience.

/images/20200527_093640.png

Backups

Discourse has two forms of backups tarball backups and s3 backups. We highly recommend s3 backups since they are more cost effective and provide stronger data guarantees. Each backup is between 70-100 MB and frequency and number of backups stored is all configurable. Thus it is possible to backup for nearly free. Further instructions on discourse backup.

The relevant s3 settings for backups can be found in Settings and searching for the term s3. If you are using aws you will only need to set the s3 access key and s3 secret access key. Note that these credentials must have create and write access to the specific bucket.

For the purpose of this demo we will be using an s3 compatible bucket on digital ocean named Spaces.

  1. Click on the create button and select spaces

/images/20200619_093943.png

  1. Choose a datasource region, ensure that we restrict file listing (making files private), and assign a unique name. For some reason in this demo the new york region was not available. I recommend selecting the closest region to the discourse droplet (does not matter how close it is to users).

/images/20200619_094322.png

Once you have created the spaces bucket note the unique name that you assigned. This will be the bucket name. In addition the datasource region you chose will determine the s3 endpoint. To find the s3 endpoint of the new bucket you created click settings in the spaces menu.

/images/20200619_095311.png

Now we need to create the access key and secret key for access to this bucket. Click "API" in the global menu and Generate New Key. Assign a memorable name that gives the purpose of the key (e.g. <project>-discourse-backup).

/images/20200619_095440.png

Once you click provide a name and access two strings will appear the top being your access key and the bottom being the secret access key. Key a note of the secret access key since you will not be able to retrieve it later (you may regenerate a new secret however).

With all this we now have:

s3 endpoint

<region>.digitalocean.com

s3 backup bucket

<unique name>

s3 access key

askdfjhaskf....

s3 secret access key

qwerqwerqwasdfasdfer....

Edit these fields in the discourse backup settings. Finally adjust the backup frequency and maximum backups. Note that each backup is around 100MB and s3 costs around $0.02-$0.05/GB so this is practically free when compared with the cost of the discourse droplet.

Plugins

Adding plugins is also quite straightforward with discourse. ssh into discourse droplet with username root and configure the app.yaml located in /var/discourse/containers/app.yaml.

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-chat-integration.git

Just add the plugins to the list. See here for additional details. Finally re-deploy the website the launcher executable in /var/discourse.

  launcher rebuild app

Upgrade

Discourse upgrades can be done through the web UI. Go to the admin settings dashboard and click "Perform upgrades here". If you have upgrades available click the upgrade buttom. Note that each upgrade will lead to 1-2 minutes of downtime for the website. In this demo's case the website is up to date. Remember to update frequently. You will receive an email about once a month about available upgrades.

/images/20200527_094820.png

Footnotes


1

recommended should only be taken as a default if you don't know what one to choose. Often they are recommended due to generous free tier