Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,14 @@ podman compose \
-f compose.yml \
up -d
```


---

### Multiple servers
When running multiple Rocket.Chat servers, you can configure Traefik to discover those servers and include them in load balancing by adding a variable in the `.env` file:

```env
ROCKETCHAT_BACKEND_SERVERS=rocketchat-1:3000,rocketchat-2:3000,rocketchat-3:3000
```

53 changes: 33 additions & 20 deletions compose.traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,39 @@ services:
traefik-init:
image: docker.io/alpine:latest
entrypoint: sh
environment:
ROCKETCHAT_BACKEND_SERVERS: ${ROCKETCHAT_BACKEND_SERVERS:-rocketchat:3000}
command:
- -c
- |-
set -e
# quote 'eof' to prevent variable expansion
rm -rf /traefik_config/* || true
mkdir -p /traefik_config/http /traefik_config/https
cat <<'EOF' | tee /traefik_config/http/dynamic.yml
# this should be idented so it works inside the heredoc concatenation later
cat <<'EOF' > /traefik_config/services.tpl
services:
grafana:
loadBalancer:
servers:
- url: "http://grafana:3000"
rocketchat:
loadBalancer:
healthCheck:
path: /health
interval: 10s
timeout: 3s
servers:
EOF

echo "ROCKETCHAT_BACKEND_SERVERS $$ROCKETCHAT_BACKEND_SERVERS"
# append the server list to the services template
for server in $(echo $$ROCKETCHAT_BACKEND_SERVERS | tr "," "\n"); do
echo " - url: \"http://$$server\"" >> /traefik_config/services.tpl
done


cat <<'EOF' > /traefik_config/http/dynamic.yml
http:
routers:
rocketchat:
Expand All @@ -27,18 +52,9 @@ services:
{{ else }}
Host(`{{ env "GRAFANA_DOMAIN" }}`)
{{ end }}
services:
rocketchat:
loadBalancer:
servers:
- url: "http://rocketchat:3000"
grafana:
loadBalancer:
servers:
- url: "http://grafana:3000"
EOF

cat <<'EOF' | tee /traefik_config/https/dynamic.yml
cat <<'EOF' > /traefik_config/https/dynamic.yml
https:
address: ":443"
http:
Expand Down Expand Up @@ -67,17 +83,14 @@ services:
service: grafana
tls:
certResolver: le
services:
rocketchat:
loadBalancer:
servers:
- url: "http://rocketchat:3000"
grafana:
loadBalancer:
servers:
- url: "http://grafana:3000"
EOF

cat /traefik_config/services.tpl >> /traefik_config/http/dynamic.yml
cat /traefik_config/services.tpl >> /traefik_config/https/dynamic.yml
cat /traefik_config/http/dynamic.yml
echo "-------------------------"
cat /traefik_config/https/dynamic.yml

echo "files generated, keeping container alive to podman-compose detect it"
tail -f /dev/null

Expand Down