How to Install Discourse Forum with Docker on CentOS 8

How to Install Discourse Forum with Docker on CentOS 8

How to Install Discourse Forum with Docker on CentOS 8

Discourse is a free and open-source platform built for the next decade of the Internet. It is a modern forum software that can be used as a mailing list, discussion forum, long-form chat room, and more. It uses Ruby on Rails for the backend, Ember.js for the front end, PostgreSQL as a data store, and Redis as a caching server. It is simple, efficient, mobile-friendly, customizable, and makes online discussion easy and fun.

In this tutorial, we will show you how to install Discourse forum using Docker on CentOS 8 server.

Prerequisites

  • A server running CentOS 8.
  • A valid domain name pointed with your server IP.
  • A root password is configured the server.

Install Docker

First, you will need to install Docker in your server. By default, Docker is not available in the CentOS 8 standard repository. So you will need to add the Docker official repo to your system. You can add it with the following command:

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Once the repo is created, install the Docker by running the following command:

dnf install docker-ce --nobest

After installing Docker, start the Docker service and enable it to start at system reboot with the following command:

systemctl start docker
systemctl enable docker

You can now verify the Docker version using the following command:

docker --version

You should see the following output:

Docker version 20.10.1, build 831ebea

Install Discourse

First, create a directory for Discourse with the following command:

mkdir /opt/discourse

Next, download the latest version of Discourse from the Git repository using the following command:

git clone https://github.com/discourse/discourse_docker.git /opt/discourse

Next, change the directory to Discourse and install the Discourse with the following command:

cd /opt/discourse
./discourse-setup

You will be asked to provide your FQDN as shown below:

which: no docker.io in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
which: no docker.io in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
Ports 80 and 443 are free for use
'samples/standalone.yml' -> 'containers/app.yml'
Found 4GB of memory and 2 physical CPU cores
setting db_shared_buffers = 1024MB
setting UNICORN_WORKERS = 4
containers/app.yml memory parameters updated.

Hostname for your Discourse? [discourse.example.com]: discourse.linuxbuz.com

Provide your valid domain name and press Enter. You will be asked to provide your valid email address and password:

Checking your domain name . . .
Connection to discourse.linuxbuz.com succeeded.
Email address for admin account(s)? [[email protected],[email protected]]: [email protected]
SMTP server address? [smtp.example.com]: smtp.gmail.com
SMTP port? [587]: 
SMTP user name? [[email protected]]: [email protected]
SMTP password? [pa$$word]: yourpassword
Optional email address for Let's Encrypt warnings? (ENTER to skip) [[email protected]]: [email protected]

Does this look right?

Provide all the details and press Enter. You will need to verify all the setup as shown below:

Hostname      : discourse.linuxbuz.com
Email         : [email protected]
SMTP address  : smtp.gmail.com
SMTP port     : 587
SMTP username : [email protected]
SMTP password : yourpassword
Let's Encrypt : [email protected]

ENTER to continue, 'n' to try again, Ctrl+C to exit: 

If everything is fine then press Enter to start the installation. Once the installation has been completed, you should get the following output:

+ /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=4 -e UNICORN_SIDEKIQS=1 -e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 -e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 -e RUBY_GC_HEAP_INIT_SLOTS=400000 -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 -e DISCOURSE_DB_SOCKET=/var/run/postgresql -e DISCOURSE_DB_HOST= -e DISCOURSE_DB_PORT= -e LETSENCRYPT_DIR=/shared/letsencrypt -e DISCOURSE_HOSTNAME=discourse.linuxbuz.com -e [email protected] -e DISCOURSE_SMTP_ADDRESS=smtp.gmail.com -e DISCOURSE_SMTP_PORT=587 -e [email protected] -e DISCOURSE_SMTP_PASSWORD=yourpassword -e [email protected] -h centos8-app -e DOCKER_HOST_IP=172.17.0.1 --name app -t -p 80:80 -p 443:443 -v /var/discourse/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address 02:e0:37:60:d3:09 local_discourse/app /sbin/boot
ab3bdf3c169d47d9ff06052f48ff078d46393f1152b651b9fd3354594cc38714

You can now verify the Discourse running container with the following command:

docker ps

You should see the following output:

CONTAINER ID   IMAGE                 COMMAND        CREATED          STATUS          PORTS                                      NAMES
ab3bdf3c169d   local_discourse/app   "/sbin/boot"   22 seconds ago   Up 21 seconds   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   app

Access Discourse Web UI

Now, open your web browser and type the URL https://discourse.linuxbuz.com. You will be redirected to the Discourse setup screen:

Discourse installation successful

Click on the Register button. You should see the Registration page:

Register admin account

Provide your email, username, password and click on the Register button. You should receive an email to activate your account.

Confirm email

Conclusion

Congratulations! you have successfully installed Discourse forum software on CentOS 8. You can now explore the Discourse for more features and deploy it in the production environment. Feel free to ask me if you have any questions.

About the Author

Leave a Reply