Your Rocket.Chat version: 0.44.0, Docker version 1.10.3, Docker-compose 1.8.0
I created docker-compose version '2' file so I could scale the service with:
docker-compose scale rocketchat=3
This seems to be reasonable as node.js apps use only 1 core so I wanted to have 3 of them running on 1 host.
Rocketchat declaration looks like this:
version: '2'
services:
rocketchat:
image: rocketchat/rocket.chat:latest
volumes:
- ./uploads:/app/uploads
environment:
- PORT=3000
# set FQDN here
- ROOT_URL=https://${ROCKETCHAT_URL}
- MONGO_URL=mongodb://mongo:27017/rocketchat
- MONGO_OPLOG_URL=mongodb://mongo:27017/local
networks:
- front-tier
- back-tier
The thing is, that as described in #4525 the instances are not synced.
I know that the solution was to use INSTANCE_IP= but here it is not possible. Rocketchat container is declared one single time in docker-compose.yml file and then scaled as a service.
Any ideas?
+
@rodrigok is the documentation for this ready?
@zahaim a nice little trick you can use is to a command field like this:
command: /bin/sh -c 'INSTANCE_IP=$$(hostname -i) node main.js'
This sets the INSTANCE_IP right before starting rocket.chat.
Hi @geekgonecrazy
I added the command you mentioned in my docker-compose.yml and it worked like a charm!
This makes scaling rocketchat easy with docker-compose / swarm mode. Thanks!
@zahaim you'll wanna change that to a lower case i in the command. hostname -I includes a space after it breaking interconnect. hostname -i does not.
I edited above so anyone else that comes across will use the correct one
@geekgonecrazy yeah, I figured it out. Still, many thanks for the idea.
I knew before that setting up INSTANCE_IP as a variable was a solution but I was sure that it was also needed to add the array of all instances like:
extra_hosts:
- "rocket-1:10.250.250.13"
- "rocket-2:10.250.250.14"
- "rocket-3:10.250.250.17"
But, as far as I can see this is not necesary so your solution works perfect. I only struggle with File Uploads now but I guess the reason is that I mount the same fs to many containers. I will check if nfs is an option.
@zahaim if you are using Gridfs or filesystem check out #6926
Basically if on same server you can mount /tmp to all containers. If not on same server until that bug is fixed... You'll need to use something like Minio or another block store
@geekgonecrazy - yep, this is the case for me.
I used your workaround (thanks) as I have it on 1 server. I will follow the other issue before switching to swarm.
GlusterFS + Docker Storage Plugin "local-perist" did it for me on a multi-node swarm cluster.
Most helpful comment
@zahaim a nice little trick you can use is to a command field like this:
This sets the INSTANCE_IP right before starting rocket.chat.