How to get your own private Rocket.Chat
In the wake of slack, private chat has become a major thing in the tech world, but it is by far not the only chat solution for teams available. This blog will introduce you to Rocket.Chat and how to get your personal instance up and running in no time.
Rocket.Chat is an open source webchat platform with a great active community around it. Releases happen on average about every 10 days. It comes with all the features you would expect, like group chats, private channels, history, notifications, message pinning, mobile clients and so on. Even if you are looking for an embedded live chat option for your website, look no further!
All in all, it is great chat option for a private company chat or a public channel to interact with your community. We, at Cloudron, use it day in day out and are very happy with it. Join us here to see how it works.
Let me explain how to install your own private Rocket.Chat.
Your own instance
The common way is to selfhost and install Rocket.Chat on a virtual server. You can do so by following the step-by-step instructions on the wiki. If you have ever administrated a server, this should be an easy yet time consuming task. Unfortunately, doing so is only the first step. For a usable instance one has to take care of DNS entries, setting up a SSL certificate and maintaining backups. In addition, tracking Rocket.Chat releases is a time consuming task and requires attention every so often, given how fast the project moves forward. Every update cycle requires at least basic testing after applying the new release.
This is where the Cloudron comes to your help. We have automated all these steps for you. Getting a fully functional Rocket.Chat instance is a matter of finding Rocket.Chat in our Cloudron Store, selecting a subdomain for the app (eg. chat.cloudron.io) and watch the progress bar reach 100%. Since we track new releases for you, we will ensure timely updates, pushed to your private instance. In addition to the basic update, we have also written tests to ensure the app will work after an update.
As we have packaged Rocket.Chat for the Cloudron, it takes advantage of other features like automatic backups and our addons, like sendmail to allow Rocket.Chat to notify users by email, if they have missed messages. These addons come preconfigured, which again just removes grunt work. For email sending, this means setting up the email related DNS records.
How we packaged Rocket.Chat
Rocket.Chat is a meteor based application. This makes it easy to package for a Cloudron.
Cloudron app packages consist basically of three files. A manifest file CloudronManifest.json
, a Dockerfile
which will base the images from our cloudron/base
image and a start.sh
, serving as the entry point for the container. You can read more about this in our docs.
Since we deal with a nodejs application, we choose a suitable node version from the base image, download the Rocket.Chat release tarball and ensure the dependencies are installed via npm. Then, we hand off to app entry point start.sh
.
The Dockerfile looks like this:
FROM cloudron/base:0.8.0
EXPOSE 3000
ENV PATH /usr/local/node-0.10.40/bin:$PATH
RUN mkdir -p /app/code
WORKDIR /app/code
RUN curl -SLf "https://rocket.chat/releases/0.21.0/download" | tar -zxf - -C /app/code && cd /app/code/bundle/programs/server && npm install && npm cache clear
ADD start.sh /app/code/start.sh
CMD [ "/app/code/start.sh" ]
The CloudronManifest.json reveals all the addons we use:
"addons": {
"localstorage": {},
"mongodb": {},
"ldap": {},
"sendmail": {}
},
The start.sh
merely consists of setting config values, to use the above Cloudron addons. If we take the sendmail addon as an example, we can directly inject those into mongodb (which is in turn an addon!):
mongo_cli="mongo ${MONGODB_HOST}:${MONGODB_PORT}/${MONGODB_DATABASE} -u ${MONGODB_USERNAME} -p ${MONGODB_PASSWORD}"
${mongo_cli} --eval "db.rocketchat_settings.update({ _id: \"SMTP_Host\" }, { \$set: { value: \"${MAIL_SMTP_SERVER}\" }}, { upsert: true })"
${mongo_cli} --eval "db.rocketchat_settings.update({ _id: \"SMTP_Port\" }, { \$set: { value: \"${MAIL_SMTP_PORT}\" }}, { upsert: true })"
${mongo_cli} --eval "db.rocketchat_settings.update({ _id: \"From_Email\" }, { \$set: { value: \"${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}\" }}, { upsert: true })"
All addons expose the relevant information to use it as environment variables. That makes is easy to incorporate into a start.sh entry point.
To offer best Cloudron integration, we also take advantage of the LDAP addon and have configured Rocket.Chat for it. The configuration is similar to sendmail. For more details, you can see the package start.sh.
As a last remaining step, we need to run the Rocket.Chat node application with a non-root user:
exec /usr/local/bin/gosu cloudron:cloudron node /app/code/bundle/main.js
That is it.
You can see the full packaging code at the rocketchat-app repository. Likely this repo will already package an updated version of Rocket.Chat.
Of course, none of the packaging steps are needed, since we already track Rocket.Chat releases and publish the app accordingly to the Cloudron Store. This allows you to focus on using the app, instead of maintaining it.