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 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!
Code:
mongod --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
db.createUser({user: "admin", pwd: "xxxxxxxx", roles: [{role: "readWrite", db: "db"}]})
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' } ]})
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 on 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:yourRootPass@db:27017/db?authSource=admin&directConnection=true
MONGO_OPLOG_URL = mongodb://root:yourRootPass@db:27017/local?authSource=admin&directConnection=true
ROOT_URL = http://localhost:3000
PROBLEMS connecting RC to MongoDB
ERROR:
In this case, run the following command:
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!