I want to install Rocket.Chat Community Version on my site and then use the Discourse Chat integration for Rocket.Chat. I made this guide through a discussion with OpenAI O3. Can someone confirm these steps are correct to get the Docker Rocket.Chat instance deployed? Just trying to not cause unforeseen consequences for not knowing how to do this correctly.
Thanks!
Step 1: Configure Your DNS in Cloudflare
- Log into Cloudflare and add an A record (or CNAME) for chat.website.com pointing to your server’s IP address.
- Make sure the Cloudflare proxy is enabled if you want to use their security and performance features.
Step 2: Set Up the Rocket.Chat Deployment
- SSH into your server and create a directory for Rocket.Chat (if you haven’t already):
bash
Copy
mkdir -p /opt/rocket.chat
cd /opt/rocket.chat - Create a docker-compose.yml file in this directory with the following content:
yaml
Copy
version: “3.8”
services:
rocketchat:
image: rocket.chat:latest
restart: unless-stopped
environment:
- PORT=3000
- ROOT_URL=http://chat.website.com
- MONGO_URL=mongodb://mongo:27017/rocketchat?replicaSet=rs0
- MONGO_OPLOG_URL=mongodb://mongo:27017/local?replicaSet=rs0
depends_on:
- mongo
ports:
- “3000:3000”
volumes:
- rocketchat_data:/app/uploads
networks:
- common
mongo:
image: mongo:4.0
restart: unless-stopped
command: mongod --smallfiles --oplogSize 128 --replSet rs0
volumes:
- mongo_data:/data/db
networks:
- common
volumes:
rocketchat_data:
mongo_data:
networks:
common:
external: false
Notes:
• The ROOT_URL is set to your subdomain (using HTTP here because Cloudflare and Caddy will handle TLS externally).
• Both services are attached to a custom network named common. This ensures that your Caddy container can resolve the service name rocketchat when proxying requests.
Step 3: Initialize MongoDB Replica Set
- Start the Rocket.Chat stack:
bash
Copy
docker-compose up -d - Get the container ID or name for MongoDB:
bash
Copy
docker ps - Connect to MongoDB:
bash
Copy
docker exec -it <mongo_container_id_or_name> mongo - In the Mongo shell, run:
js
Copy
rs.initiate() - Exit the shell with exit.
This step initializes the replica set that Rocket.Chat uses for real time operations.
Step 4: Update Your Caddy Configuration
Since Caddy is already running in its own container, update its Caddyfile to include a new site block for Rocket.Chat. Edit your Caddyfile (for example, located at /path/to/your/Caddyfile) and add:
caddy
Copy
http://chat.website.com {
reverse_proxy rocketchat:3000
}
Important:
• The reverse_proxy directive uses the service name rocketchat—this requires that the Caddy container is on the same Docker network as the Rocket.Chat containers.
• If your Caddy container is managed via Docker Compose, you can attach it to the same common network. For example, in your Caddy container’s docker-compose file, add:
yaml
Copy
networks:
- common
And ensure the network is declared (or attach the container manually).
Since you’re using Cloudflare for DNS and Let’s Encrypt, and you already have your working configuration without an email directive, no changes are needed regarding TLS.
Step 5: Reload Caddy and Verify the Setup
- Reload Caddy:
If you’re running Caddy via Docker, restart the container so that it picks up the new Caddyfile configuration:
bash
Copy
docker restart <caddy_container_name> - Test Your Deployment:
Open a web browser and navigate to http://chat.website.com. (Cloudflare will manage the HTTPS certificate.) You should see the Rocket.Chat setup page. - Complete the Setup:
Follow the on-screen instructions to finish configuring Rocket.Chat.
Additional Customization
If you need to add further environment variables (for example, SMTP settings or custom volumes) or have any specific network requirements, let me know so the guide can be refined further.
This guide should help you deploy Rocket.Chat Community Edition with Docker Compose on a subdomain managed by Cloudflare, using Caddy (in its own container) as the reverse proxy.