← Back to RocketChat/Rocket.Chat

How to Deploy & Use RocketChat/Rocket.Chat

Rocket.Chat Deployment and Usage Guide

Prerequisites

System Requirements

  • Node.js: v16.x or later
  • MongoDB: v4.4 or later
  • npm: v7.x or later
  • Git: Latest version

Required Accounts

  • MongoDB Atlas (or self-hosted MongoDB instance)
  • GitHub account (for cloning the repository)

Installation

1. Clone the Repository

git clone https://github.com/RocketChat/Rocket.Chat.git
cd Rocket.Chat

2. Install Dependencies

npm install

3. Build the Application

npm run build

Configuration

Environment Variables

Create a .env file in the root directory with the following variables:

# MongoDB Connection
MONGO_URL=mongodb://localhost:27017/rocketchat
MONGO_OPLOG_URL=mongodb://localhost:27017/local

# Server Configuration
ROOT_URL=http://localhost:3000
PORT=3000

# Email Configuration (optional)
MAIL_URL=smtp://user:pass@mailserver.com:587

# File Upload Configuration
UPLOADS_PATH=./uploads

Configuration Files

  • settings.json: Contains default settings for the Rocket.Chat instance
  • translations.json: Contains localization strings

API Keys

  • Google OAuth: For Google authentication
  • GitHub OAuth: For GitHub authentication
  • Slack Bridge: For Slack integration (if using)

Build & Run

Development Mode

npm run dev

Production Mode

npm run start

Docker Development

docker-compose up -d

Docker Production

docker-compose -f docker-compose.prod.yml up -d

Deployment

Docker Deployment

docker run -d \
  --name rocketchat \
  -e MONGO_URL=mongodb://mongo:27017/rocketchat \
  -e ROOT_URL=http://localhost:3000 \
  -p 3000:3000 \
  rocketchat/rocket.chat:latest

Kubernetes Deployment

kubectl apply -f https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml

Recommended Platforms

  • AWS: EC2 with RDS for MongoDB
  • DigitalOcean: Droplet with MongoDB Atlas
  • Google Cloud: Compute Engine with Cloud SQL
  • Azure: Virtual Machine with Cosmos DB

Troubleshooting

Common Issues

1. MongoDB Connection Error

Symptom: Application fails to start with MongoDB connection errors Solution:

# Check MongoDB status
mongod --status

# Restart MongoDB
sudo systemctl restart mongod

2. Port Conflict

Symptom: Port 3000 is already in use Solution:

# Check running processes on port 3000
lsof -i :3000

# Kill the process
kill -9 <PID>

3. Build Errors

Symptom: npm build fails with dependency errors Solution:

# Clear npm cache
npm cache clean --force

# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install

4. Memory Issues

Symptom: Application crashes due to memory constraints Solution:

# Increase Node.js memory limit
export NODE_OPTIONS=--max-old-space-size=4096

5. SSL Certificate Issues

Symptom: HTTPS connections fail Solution:

# Generate self-signed certificate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

# Configure SSL in .env
ROOT_URL=https://yourdomain.com

Logs and Monitoring

# Check application logs
tail -f logs/rocketchat.log

# Check MongoDB logs
tail -f /var/log/mongodb/mongod.log

Performance Optimization

  • Enable MongoDB indexing for better query performance
  • Configure Redis for caching
  • Set up proper backup strategies for MongoDB
  • Monitor system resources regularly

Security Best Practices

  • Use HTTPS for all communications
  • Regularly update dependencies
  • Implement proper access controls
  • Enable two-factor authentication
  • Regular security audits and penetration testing