Rocket.Chat is a great alternative to tools like Slack, offering real-time messaging, voice, and video conferencing. Setting it up might seem a bit tricky, but this guide will walk you through the process.
We’ll deploy Rocket.Chat using Docker Compose, with MongoDB as its database and Traefik handling HTTPS and routing as the reverse proxy. Let’s get started!
What You’ll Need
Before we dive in, here’s your checklist:
- VPS or local server with Docker and Docker Compose installed.
- A domain name (e.g.,
chat.yourdomain.com
) pointing to your server. - Traefik set up as your reverse proxy.
Step 1: Set Up Your Project Directory
Keep things clean. Create a directory for your Rocket.Chat setup:
mkdir -p ~/rocketchat-setup && cd ~/rocketchat-setup
Step 2: Create Your Docker Compose File
Now, let’s bring Rocket.Chat and MongoDB to life. Create a file called docker-compose.yml
and paste this configuration:
volumes:
mongodb_data: { driver: local }
services:
rocketchat:
image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}
restart: always
labels:
traefik.enable: "true"
traefik.http.routers.rocketchat.rule: Host(`${DOMAIN:-}`)
traefik.http.routers.rocketchat.tls: "true"
traefik.http.routers.rocketchat.entrypoints: https
traefik.http.routers.rocketchat.tls.certresolver: le
environment:
MONGO_URL: "${MONGO_URL:-\
mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
-mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3333}}
PORT: ${PORT:-3333}
DEPLOY_METHOD: docker
DEPLOY_PLATFORM: ${DEPLOY_PLATFORM:-}
REG_TOKEN: ${REG_TOKEN:-}
depends_on:
- mongodb
expose:
- ${PORT:-3333}
ports:
- "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3333}:${PORT:-3333}"
mongodb:
image: docker.io/bitnami/mongodb:${MONGODB_VERSION:-6.0}
restart: always
volumes:
- mongodb_data:/bitnami/mongodb
environment:
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
What’s Happening Here?
- Rocket.Chat Service: Handles chat functionality and connects to MongoDB for data storage.
- MongoDB Service: A robust database backend, configured for Rocket.Chat’s needs.
- Traefik Labels: Configures Rocket.Chat to use HTTPS, handled automatically by Traefik with Let’s Encrypt.
Step 3: Set Environment Variables
Before we start the stack, set up your .env
file to store sensitive configurations. Create a file called .env
and add the following:
DOMAIN=chat.yourdomain.com
RELEASE=latest
HOST_PORT=3333
PORT=3333
MONGODB_DATABASE=rocketchat
MONGODB_REPLICA_SET_NAME=rs0
ALLOW_EMPTY_PASSWORD=yes
Replace chat.yourdomain.com
with your actual domain name.
Step 4: Fire Up the Stack
Start your Rocket.Chat stack with:
docker-compose up -d
Docker will pull the images, create containers, and launch Rocket.Chat and MongoDB.
Step 5: Verify the Deployment
Once the services are up, here’s how to confirm everything is working:
- Open your browser and navigate to
https://chat.yourdomain.com
. - Log in using the Rocket.Chat setup wizard.
- Test the real-time messaging and admin dashboard.
Wrapping Up
This setup gives you:
- Real-time communication for your team or community.
- Secure HTTPS with Traefik and Let’s Encrypt.
- Scalable architecture powered by Docker.
Happy deployment! 🚀