Rocket.Chat Docker Compose
#
Folder Structure
#
# Create folder structure
sudo mkdir -p /opt/rocketchat/{data,uploads} && cd /opt/rocketchat
Docker Compose File
#
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.8'
services:
mongo:
image: mongo:4.2
restart: unless-stopped
volumes:
- ./data:/data/db
command: mongod --oplogSize 128 --replSet rs0
healthcheck:
test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"]
interval: 30s
timeout: 10s
retries: 5
mongo-init-replica:
image: mongo:4.2
command: >
bash -c "for i in `seq 1 30`; do
mongo mongo/rocketchat --eval \"rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})\" && s=$$? && break || s=$$?;
echo \"Tried $$i times. Waiting 5 secs...\";
sleep 5;
done;
(exit $$s)"
depends_on:
mongo:
condition: service_healthy
rocketchat:
image: rocketchat/rocket.chat:4.5.0
restart: unless-stopped
ports:
- "127.0.0.1:3000:3000"
depends_on:
mongo:
condition: service_healthy
command: >
bash -c "sleep 15; for i in `seq 1 30`; do
node main.js && s=$$? && break || s=$$?;
echo \"Tried $$i times. Waiting 5 secs...\";
sleep 5;
done;
(exit $$s)"
environment:
- MONGO_URL=mongodb://mongo/rocket
- MONGO_OPLOG_URL=mongodb://mongo/local
- ROOT_URL=https://rocketchat.jklug.work
volumes:
- ./uploads:/app/uploads
Start Container
#
# Create / start Docker Compose stack
sudo docker compose up -d
# Check logs
sudo docker compose logs -f
# Wait till logs show:
rocketchat-rocketchat-1 | +------------------------------------------------------+
rocketchat-rocketchat-1 | | SERVER RUNNING |
rocketchat-rocketchat-1 | +------------------------------------------------------+
rocketchat-rocketchat-1 | | |
rocketchat-rocketchat-1 | | Rocket.Chat Version: 4.5.0 |
rocketchat-rocketchat-1 | | NodeJS Version: 14.18.3 - x64 |
rocketchat-rocketchat-1 | | MongoDB Version: 4.2.24 |
rocketchat-rocketchat-1 | | MongoDB Engine: wiredTiger |
rocketchat-rocketchat-1 | | Platform: linux |
rocketchat-rocketchat-1 | | Process Port: 3000 |
rocketchat-rocketchat-1 | | Site URL: https://rocketchat.jklug.work |
rocketchat-rocketchat-1 | | ReplicaSet OpLog: Enabled |
rocketchat-rocketchat-1 | | Commit Hash: 3901054684 |
rocketchat-rocketchat-1 | | Commit Branch: HEAD |
rocketchat-rocketchat-1 | | |
rocketchat-rocketchat-1 | +------------------------------------------------------+
Reverse Proxy
#
Certbot
#
# Install Certbot
sudo apt install certbot -y
# Create certificate
sudo certbot certonly --standalone -d rocketchat.jklug.work
Nginx
#
# Install nginx
sudo apt install nginx -y
# Copy default config
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/rocketchat.jklug.work
# Edit config
sudo vi /etc/nginx/sites-available/rocketchat.jklug.work
# rocketchat.jklug.work
server {
listen 443 ssl;
server_name rocketchat.jklug.work;
ssl_certificate /etc/letsencrypt/live/rocketchat.jklug.work/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rocketchat.jklug.work/privkey.pem;
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Disable default config
sudo rm /etc/nginx/sites-enabled/default
# Enable config
sudo ln -s /etc/nginx/sites-available/rocketchat.jklug.work /etc/nginx/sites-enabled/
# Restart Nginx
sudo systemctl restart nginx
Rocket.Chat
#
# Open URL
rocketchat.jklug.work