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:
- A Dockerized Web Service that runs the Discourse website and background workers.
- A Render PostgreSQL Managed Database.
- A Redis instance for caching and acting as a message queue for the background workers.
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?
If you need help, get in touch at https://community.render.com.
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.
You will be prompted to input several environment variables, some of which are optional. See below for more details
Manual Deployment
- Create a managed PostgreSQL database. We recommend the
Standard
plan which should be enough for small to medium communities. - Create a Redis instance. The
Starter
plan with a 4 GB disk should be enough to start with, but you should continue to monitor usage metrics as your community grows. - Fork render-examples/discourse on GitHub or click the green ‘Use this template’ button.
- Create a new Web Service on Render, and give Render permission to access your new repo.
- Make sure the
Environment
is set toDocker
, and enter a name for the service (this will be used to generate the private URL). -
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 Deploy No
-
Add a Disk under Disks with the following values:
Name discourse-data
Mount Path /var/www/discourse/public/uploads
Size 2 GB
Feel free to change this to suit your needs. -
Add the following environment variables under Environment. These must be set appropriately for your application to work.
Key Value DISCOURSE_ADMIN_EMAIL
a valid email address for the admin account DISCOURSE_ADMIN_PASSWORD
a password for the admin account. This must be over 15 characters long DISCOURSE_DB_HOST
hostname from your PostgreSQL database DISCOURSE_DB_NAME
database name from your PostgreSQL database DISCOURSE_DB_PASSWORD
password from your PostgreSQL database DISCOURSE_DB_PORT
port from your postgresql database discourse_db_username
username from your PostgreSQL database DISCOURSE_REDIS_HOST
host from your private redis service DISCOURSE_REDIS_PORT
port from your private redis service DISCOURSE_SMTP_ADDRESS
the address of your SMTP provider (e.g. smtp.mailgun.org
)DISCOURSE_SMTP_DOMAIN
The domain you will send emails from (e.g. for my_email@mg.example.com
, it would bemg.example.com
)DISCOURSE_SMTP_PASSWORD
your SMTP provider password DISCOURSE_SMTP_PORT
the port your SMTP provider uses to connect (e.g. 587
)DISCOURSE_SMTP_USER_NAME
your SMTP provider username (e.g. postmaster@mg.example.com
)PORT
80
-
Optional These environment variables can be used to further customize your deployment. You do not need to set them unless you need their functionality.
Key Value CUSTOM_DOMAIN
the 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
subdomainDISCOURSE_MAXMIND_LICENSE_KEY
GeoLite2 license key, useful for user analytics - Click
Create Web Service
and you’re good to go! Once deployed, your Discourse instance will be available for you on either anonrender.com
or youCUSTOM_DOMAIN
!
Setup
- Optional If you used a custom domain for the deployment, don’t forget to configure your DNS!
- 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
. - 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.
Resource Optimization
We have configured the following:
- web server: uses 2 workers and 4 threads.
- background worker: concurrency level 2.
This works well on a machine with 2 GB RAM, but you can choose a larger web server plan depending on your forum traffic. 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