Deploy Discourse


Discourse is modern software for your community. Use it as a mailing list, discussion forum, long-form chat room, and more. You can use this repo to self-host Discourse on Render in just a few clicks! It will create the following components on Render:


This deployment has several advantages over the official Discourse install guide:

  • Free, fully managed SSL for your Render subdomain and custom domains.
  • Improved scalability and reliability through an independent service for each component.
  • Officially supported by Render
  • Did we mention 1-click deploy?

Deployment

Prerequisites

Discourse does not work without an email server. Setting up and managing mail servers can be tricky, so we’ve omitted a mail server from the deploy config and strongly recommend using a third-party email provider.

See the official Discourse recommended email providers.

We have tested this repo successfully with Mailgun, but other providers in the list above should work equally well.

One Click Deploy

Use the button below to deploy Discourse on Render.

Deploy to Render

You will be prompted to input several environment variables, some of which are optional. See below for more details

Manual Deployment

  1. Create a managed PostgreSQL database. The Starter Plan is enough to get you up and running.

  2. Fork render-examples/discourse on GitHub or click the green ‘Use this template’ button.

  3. Create a new Web Service on Render, and give Render permission to access your new repo.

  4. Make sure the Environment is set to Docker, and enter a name for the service (this will be used to generate the private URL).

  5. Expand the Advanced section and edit the following values.

    Health Check Path/srv/status
    Docker Build Context Directory./web/v2.6.3
    Dockerfile Path./web/v2.6.3/Dockerfile
    Auto DeployNo
  6. Add a Disk under Disks with the following values:

    Namediscourse-data
    Mount Path/var/www/discourse/public/uploads
    Size12 GB Feel free to change this to suit your needs.
  7. Add the following environment variables under Environment. These must be set appropriately for your application to work.

    KeyValue
    DISCOURSE_ADMIN_EMAILa valid email address for the admin account
    DISCOURSE_ADMIN_PASSWORDa password for the admin account. This must be over 15 characters long
    DISCOURSE_DB_HOSThostname from your PostgreSQL database
    DISCOURSE_DB_NAMEdatabase name from your PostgreSQL database
    DISCOURSE_DB_PASSWORDpassword from your PostgreSQL database
    DISCOURSE_DB_PORTport from your postgresql database
    DISCOURSE_DB_USERNAMEusername from your PostgreSQL database
    DISCOURSE_REDIS_HOSTlocalhost
    DISCOURSE_REDIS_PORT6379
    DISCOURSE_SMTP_ADDRESSthe address of your SMTP provider (e.g. smtp.mailgun.org)
    DISCOURSE_SMTP_DOMAINThe domain you will send emails from (e.g. for my_email@mg.example.com, it would be mg.example.com)
    DISCOURSE_SMTP_PASSWORDyour SMTP provider password
    DISCOURSE_SMTP_PORTthe port your SMTP provider uses to connect (e.g. 587)
    DISCOURSE_SMTP_USER_NAMEyour SMTP provider username (e.g. postmaster@mg.example.com)
    DISCOURSE_WEB_CONCURRENCYthe number of web workers running concurrently (see resource optimization)
    DISCOURSE_WORKER_CONCURRENCYthe number of background workers running concurrently (see resource optimization)
    PORT80
  8. Optional These environment variables can be used to further customize your deployment. You do not need to set them unless you need their functionality.

    KeyValue
    CUSTOM_DOMAINthe custom domain you will use for your Discourse instance. If you populate this variable you will need to configure DNS before your instance is usable. If you leave it blank, your instance will be available on a .onrender.com subdomain
    DISCOURSE_MAXMIND_LICENSE_KEYGeoLite2 license key, useful for user analytics
  9. Click Create Web Service and you’re good to go! Once deployed, your Discourse instance will be available for you on either an onrender.com or you CUSTOM_DOMAIN!

Setup

  1. Optional If you used a custom domain for the deployment, don’t forget to configure your DNS!

  2. After deploying the service, you will be able to log in with your admin email address. The password will be located in the environment variables section on your Render dashboard, under DISCOURSE_ADMIN_PASSWORD.

  3. Once you are logged in, run the setup wizard to customize your Discourse website! It should be located on a banner at the top of the page.

Discourse Welcome Screen

Resource Optimization

We have configured the following:

This works well on a machine with 1 GB RAM, but you can choose a larger web server plan depending on your forum traffic. For forums with very high traffic, it can be helpful to separate Redis into its own service. For reference, see the Discourse default server config and default worker config. These may work better on machines with more RAM.

Upgrading

Upgrading should be relatively simple since Render will store your assets on Render Disks and application data in our Database.

Render will continue to verify all new Discourse versions in our official Discourse repository. One we’ve verified a version, you can simply upgrade the Dockerfile path in your render.yaml to point to the new version and click ‘Manual Deploy’ on your dashboard.

Troubleshooting

Created with no admin account

This could happen if the admin email you specified is invalid. If this is the case, you can update the value of the DISCOURSE_ADMIN_EMAIL environment variable and the server will redeploy and create the account.

If this also fails, you can manually create an admin account through the web shell in your Render dashboard. Use the following commands:

# This will prompt you to input an email and password to create your admin account
bundle exec rake admin:create

# Restart the Discourse server
bundle exec pumactl -P pids/puma.pid restart

If you have questions or need help, feel free to get in touch at https://community.render.com.