Setup RocketChat with Mongo Cluster Volume and Traefik – Dockerized in Rancher

This assumes you have Traefik already setup in Rancher.

docker-compose.yml

version: '2'
volumes:
  mongodata:
    driver: rancher-nfs
services:
  mongo-cluster:
    image: mongo:3.4
    volumes:
    - mongodata:/data/db
    environment:
      CATTLE_SCRIPT_DEBUG: ''
      MONGO_SERVICE_NAME: mongo-cluster
    command:
    - --replSet
    - rs4
  rocketchat:
    image: rocketchat/rocket.chat:latest
    environment:
      MONGO_OPLOG_URL: mongodb://mongo-cluster:27017/local?replSet=rs4
      MONGO_URL: mongodb://mongo-cluster:27017/rocketchat
      PORT: '3000'
      ROOT_URL: https://your.domain.co.za
    links:
    - mongo-cluster:mongo-cluster
    labels:
      traefik.frontend.rule: Host:your.domain.co.za
      traefik.port: '3000'
      traefik.enable: 'true'
      traefik.protocol: http
  hubot:
    image: rocketchat/hubot-rocketchat
    environment:
      BOT_NAME: bot
      EXTERNAL_SCRIPTS: hubot-help,hubot-seen,hubot-links,hubot-diagnostics
      ROCKETCHAT_PASSWORD: yourpassword
      ROCKETCHAT_ROOM: GENERAL
      ROCKETCHAT_URL: rocketchat:3000
      ROCKETCHAT_USER: bot
    links:
    - rocketchat:rocketchat

rancher-compose.yml

version: '2'
services:
  mongo-cluster:
    metadata:
      mongo: &id001
        yml:
          replset.name: rs4
    retain_ip: true
    scale: 1
    start_on_create: true
  rocketchat:
    scale: 1
    start_on_create: true
  hubot:
    scale: 1
    start_on_create: true

Once the mongo-cluster image is active, enter the shell of that container and run the following commands to initialiate the cluster:

mongo
rs.initiate()