Setting up RocketChat on TrueNAS is not totally straightforward, but I’m here to help with that!
Table Of Contents#
- Create Datasets
- Dealing With Permission Issues
- Creating A Security KeyFile
- Download And Edit The Setup File
- Installing And Initial Setup
- For Insightful Search
Create Datasets#
First you will need to create Datasets for the database RocketChat uses and one for user uploaded content. I’ll be honest, I don’t remember if the user upload Dataset is necessary, but I includ it when I set up my system and it works. You can try without it, but if something goes wrong, try adding that back in first.
The Datasets can be anywhere on your TrueNAS system. I have my database on an SSD Pool and the user upload on an HDD pool. When creating them, choose the Apps preset. Example Dataset locations:
- Database: /mnt/SSD/apps/data/rocket-chat/mongodb
- User Uploads: /mnt/HDD/apps/storage/rocket-chat-uploads
Dealing With Permission Issues#
After creating the Datasets, I ran into some permission errors when putting the database directly into the dataset created by TrueNAS. To solve it I used the shell to create a directory inside the Dataset for the Database which in my case was /mnt/SSD/apps/data/rocket-chat/mongodb. I called it mongo, but the name doesn’t matter as long as you remember it. You can achieve this by going to the TrueNAS web interface and clicking on the System tab, then click Shell. From there use the cd to change the directory to where you made the database. In TrueNAS the storage pools live in a directory called /mnt. In my case, I have two storage pools, one called SSD and one called HDD. They exist at /mnt/SSD and /mnt/HDD. If any of the following commands say you don’t have permission, you will need to add sudo before them and type in your TrueNAS password. To change directories and create the new one I used the following commands:
- Change Directories: cd /mnt/SSD/apps/data/rocket-chat/mongodb
- Create Directory: mkdir mongo
Creating A Security KeyFile#
While we’re in the Shell we need to do one more thing. MongoDB needs a file called security.keyFile to work properly in this scenario. We can create that and give it the correct permisions using the following commands in the same directory:
- Create the File: openssl rand -base64 756 > security.keyFile
- Give it the correct permissions: chmod 400 security.keyFile
Download And Edit The Setup File#
Click here to download the docker compose template. It is an almost complete copy of what you will need to use to get RocketChat running. To make it work you will need to edit it, so open it in any text editor. Make the following changes:
- Next to MONGO_INITDB_ROOT_PASSWORD change ADMIN_PASSWORD to something else. Write it down, you will need it later.
- Under volumes:
- Change both instances of PATH_TO_DATASET to the same place you used the cd command above.
- In my case that was /mnt/SSD/apps/data/rocket-chat/mongodb
- For the line that ends in :/data/db you will need to add the name of the directory you created with the mkdir command between PATH_TO_DATASET and :/data/db.
- For me that looks like /mnt/SSD/apps/data/rocket-chat/mongodb/mongo:/data/db since I called my directory mongo.
- The line for the security.keyFile should look something like: /mnt/SSD/apps/data/rocket-chat/mongodb/security.keyFile:/etc/security.keyFile:ro
- Moving down to the lines that say MONGO_OPLOG_URL and MONGO_URL, replace ADMIN_PASSWORD with the password you chose at the top of the file.
- For the ROOT_URL replace IP_YOU_ACCESS_ROCKET_CHAT_FROM with the local IP of your TrueNAS system and replace PORT with whatever port you want to use to access it.
- Example: http://192.168.68.1.100:30000
- The image line might need to be changed to the latest version of RocketChat. At the time of writing this, the latest version is 8.1.1. You can check the latest version here. Look for the one labeled latest and use that number.
- Under ports: replace PORT_FOR_ACCESS with the same port you chose for the ROOT_URL.
- Lastly replace PATH_TO_USER_UPLOADS with the location of the dataset you made for user uploads.
- Example: /mnt/HDD/apps/storage/rocket-chat-uploads
Installing And Initial Setup#
Read the WHOLE next section, before you continue. It’s kinda time sensitive. If you aren’t able to run all the commands in time, you will need to delete the contents of the database and start again. If you need to do that, its pretty easily done with the Filebrowser app you can find in the TrueNAS Discover Apps area. Just make sure to mount the data set you made for RocketChat. If you need more time, go back to the file you just finished editing and edit the line under command: that says sleep 20. Change the 20 to whatever you need (it’s a number of seconds), just know that you will have to wait that long before RocketChat actually starts. MongoDB will start then it waits, then it starts RocketChat. After you succeed with the setup, you can change it back to sleep 20 because you only need to do the next step with all the commands once.
Tip: You can paste into the Shell in the TrueNAS web interface by pressing SHIFT + INSERT and copying is CTRL + INSERT.CTRL + C and CTRL + V do not work there.
Now that you have that set up, go to the Apps tab in TrueNAS and click Discover Apps then next to the Custom App button click the Three Dots and Install via YAML. Name it something like rocket-chat. Copy and paste everything in the file into the Custom Config box and click Save. You should be sent back to the Apps tab in TrueNAS. As soon as you see the RocketChat app in the list, click on it. You should see some info about it pop up to the right side of the list. In the box labeled Workloads under Containers look for mongodb. To the right of mongodb you should see three icons. Click the first icon (the one on the left) to open a shell inside the container to run commands. Run the following commands:
- mongosh -u root -p ADMIN_PASSWORD –authenticationDatabase admin replace ADMIN_PASSWORD with the password you set in the file form earlier.
- rs.initiate({ _id: “rs0”, members: [{ _id: 0, host: “rocketchat-mongodb:27017” }] })
- rs.status()
If the output of rs.status() contains the line stateStr: ‘PRIMARY’ inside the members section, it worked! It might also say primary in the command prompt next to where you type / paste in the commands. To verify, type http://YOUR_IP:PORT into your web browser. You will need to finish the setup in the RocketChat web interface, the hard part is done!
For Insightful Search#
If your doing this to set up Insightful Search then click either of the links below to go to the next step: