Rocket.Chat - SLACK alternative (with MongoDB as backend)

Docker Rocket.Chat - SLACK alternative (with MongoDB as backend)

265



Did you hear of SLACK? How about Discord? Microsoft Teams? Great! Then you know what this tutorial will be all about.

In this tutorial, we will focus on running an open source, private alternative to those platforms. Enter, Rocket.Chat

Just in case that you haven't heard about any of those platforms or have never used them, let say in short what RC is. In short, RC is a platform that will allow you to run your very own, private chat platform by means of using private messages, public and private channels, E2E encryption (still in beta), and even voice and audio.
On top of all this, there are also options to send files, run separate discussions, links, and more. The platform can be accessed via a web UI, and any modern mobile or desktop OS. To conclude, considering that its open source you can customize it to your needs (CSS, logo, and fonts for example).

This platform will be run via Docker considering it's not supported natively via package center (Synology has its own version called Chat). We will need 2 things. MongoDB container and RC container.
In the past month, RC DEV team has made a change on the MongoDB side that got many users upset because the new version of RC (1.0+) would not run without the proper settings on the MongoDB instance. We will cover that part as well. Let's start.

01. MongoDB container

For this setup, we can use mongo:latest image configured with the following settings (I will not post docker compose file here considering some people might use the Synodocker UI):

Port: 27017
Volume:
/your/local/folder/mongodb:/data/db
/your/local/folder/mongodb/mongod.conf:/etc/mongod.conf

Environment variables (apart from the default ones):
MONGO_INITDB_DATABASE = db
MONGO_INITDB_ROOT_USERNAME = root
MONGO_INITDB_ROOT_PASSWORD = define a pass for your root account
IMPORTANT!
Be sure that you will enter the following command in the CMD parameter when creating this container! This can be set under the Environmental variable tab (Synology Docker UI on the bottom of the tab).
Code:
mongod --smallfiles --oplogSize 128 --replSet rs0
One more thing that needs to be configured for all this to work is to prepare the conf file (that will be mapped as a volume). Open up a text editor and create one with the following content:

Code:
replication:
    replSetName: "rs0"
After you have setup the container you will need to prepare it to run in replica mode. To do that connect to your container via a command line or the Terminal tab in Syno UI (or via portainer if you are running it) using the bash command.

Now 1st thing we need is an admin mongoDB database. The reason is that we will have to convert this mongoDB instance as the 1st replica node (no matter that there will be no other nodes in the future, this is how RC currently works, and demands the setting).

After you have started bash command inside the mongodb container (via Terminal tab for example). Run the following command:

Code:
mongo -u root -p yourRootPass --authenticationDatabase admin
Make sure that root password is the same one that you have used as an env variable parameter for the MONGO_INITDB_ROOT_PASSWORD variable
If you have managed to log as root your command line will be something like rs:PRIMARY or something like that.

Now comes that most important command line that will convert your mongoDB instance as a replica. Run this as a single line command:

Code:
rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})
Make sure that rs# parameter is the same one as the one that you have entered in your conf file as well as the port number that needs to be the same as your mongoDB INTERNAL/container port. Not the port that will be visible on the host side.
With all that, we are done with mongoDB container. Damn! Let's move on.

02. Rocket.Chat container

RC image will be rocketchat/rocket.chat:latest that's the official image from RC team.

There are only several env variables that need to be configured. There are no volumes that this image use considering that all configuration and data parameters are stored in the mongoDB side.

PORT: 3000 (or some port of your choice)
LINKS: your mongoDB container > alias: db (or whatever you want)

Environment variables (apart from the default ones):
MONGO_URL = mongodb://root:[email protected]:27017/db?authSource=admin
MONGO_OPLOG_URL = mongodb://root:[email protected]:27017/local?authSource=admin

Keep in mind that db parameter after @ needs to be the same one as the one that you have used in the LINKS. Also, the port number needs to be the same one as INTERNAL/container parameter for your mongoDB
ROOT_URL = http://localhost:3000
Please note that there is no need to set the root url to a specific https fqdn considering that you can run this container via reverse proxy just like any other app
That's it! Run the container and keep your eye on the log. If all is well you will see get a nice SERVER RUNNING message in your log.

Now all that's left is to access it on its custom 3000 port and start configuring your very own private chat platform!

Latest updates

  1. Rocket.Chat DB backup and restore steps

    In case you ever need to restore your RC content to the same or a separate RC instance you might...
Top