Rocket Chat Docker Install

/ Comments off

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

Rocket.Chat application is free to download and offers easy-to-install, easy-to-use, secure, and reliable Messaging and Chat applications. This application’s primary functions are comprehensive and go beyond the features offered by others that can be considered as its rivals. To be able to access the rocket chat we can use this command to create a tunnel to the service: $ minikube service rocketchat-server. Now open the browser and enter the address generated using the previous command: You should see the welcome page. I hope this article has helped you to deploy your RocketChat server. My docker-compose.yml file/setup to run Rocket.Chat in production. Optional containers for Hubot and a complete application monitoring stack available as well.


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_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).


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:

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.
Rocket chat docker installNow 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:

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

In case you run into a problem connecting to your mongo instance using the admin DB (previous step) make sure to try and create and admin user for the db databse. Run the following command:
db.createUser({user: 'admin', pwd: 'xxxxxxxx', roles: [{role: 'readWrite', db: 'db'}]})
Use your root password (the one from the environmental variable as a password

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:

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

Install Rocket Chat Ubuntu Docker


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
Rocket
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
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. However, iOS app will have a problem with specific functions in that case. To avoid it, make sure that your ROOT_URL is the same as your public fqdn if you intend to publish this instance to the Internet.

PROBLEMS connecting RC to MongoDB
NOTE: if you run into the following problem, please log into your mongo instance using the method above and run the following commands. This error will be visible in the MongoDB container log! Also, this will probably result in an immediate crash of RC contianer upon start, so be sure to check the MongoDB side of things.

ERROR:
Authentication failed','attr':{'mechanism':'SCRAM-SHA-256','principalName':'MyUser','authenticationDatabase':'mydb','client':'127.0.0.1:2012','result':'UserNotFound: Could not find user 'MyUser' for db 'mydb'}}

Rocket Chat Docker Installation

In this case, run the following command:
db.createUser(
{
user: 'MyUser',
pwd: 'MyuserPassword',
roles: [ { role: 'userAdminAnyDatabase', db: 'mydb' } ]
}
)

Of course, MyUser can be also the root account and mydb can be the 'admin' DB, but that will depend on the ERROR output. So change it accordingly!
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!