Multi-region with V4 and Docker Compose

Hi
I am trying to setup the stack with 2 Regional bands, AS923 and AS923-4

my docker-compose looks like this:

version: "3"

services:
  chirpstack:
    image: chirpstack/chirpstack:4.0.5
    command: -c /etc/chirpstack
    restart: unless-stopped
    volumes:
      - ./configuration/chirpstack:/etc/chirpstack
      - ./lorawan-devices:/opt/lorawan-devices
    depends_on:
      - postgres
      - mosquitto
      - redis
    environment:
      - MQTT_BROKER_HOST=mosquitto
      - REDIS_HOST=redis
      - POSTGRESQL_HOST=postgres
    ports:
      - 8080:8080

  chirpstack-gateway-bridge-as923:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1700:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
    depends_on: 
      - mosquitto

  chirpstack-gateway-bridge-as923-4:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1701:1701/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge-as923-4:/etc/chirpstack-gateway-bridge
    depends_on:
      - mosquitto

  chirpstack-rest-api:
    image: chirpstack/chirpstack-rest-api:4.0.4
    restart: unless-stopped
    command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure
    ports:
      - 8090:8090
    depends_on:
      - chirpstack

  postgres:
    image: postgres:14-alpine
    restart: unless-stopped
    volumes:
      - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
      - postgresqldata:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=root

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redisdata:/data

  mosquitto:
    image: eclipse-mosquitto:2
    restart: unless-stopped
    ports:
      - 1883:1883
    volumes: 
      - ./configuration/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf

volumes:
  postgresqldata:
  redisdata:

my gateway-bridge config looks like this:

# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.

[integration.mqtt.auth.generic]
servers=["tcp://mosquitto:1883"]
username=""
password=""

[integration.mqtt]
event_topic_template="as923/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
state_topic_template="as923/gateway/{{ .GatewayID }}/state/{{ .StateType }}"
command_topic_template="as923/gateway/{{ .GatewayID }}/command/#"

and another for as923-4 in a seperate folder

# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.

[integration.mqtt.auth.generic]
servers=["tcp://mosquitto:1883"]
username=""
password=""

[integration.mqtt]
event_topic_template="as923_4/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
state_topic_template="as923_4/gateway/{{ .GatewayID }}/state/{{ .StateType }}"
command_topic_template="as923_4/gateway/{{ .GatewayID }}/command/#"

is this the correct approach here? I am not sure it is working, but still debugging with the end-device.

thanks!

Just a correction, you are using the same frequency band (AS923), what you refer to, is the use of different frequency subbands (1, 2, 3, 4, 5, 6, 7 and 8).

This subbands use different channels for up and downlinks.

I think it is not necessary to have different .toml files under the /configuration folder in docker-compose. You should enter your gateway UI and select it from there (be careful, some end-devices work on ANY subband, and others are set to work in only one of them).

Hi @NicolasUy I think AS923 and AS923-4 can be looked at as different regional bands same like AS923 and US915.

and they required a different gateway bridge configuration as well.

also this post is relevant for anyone wishing to setup 2 or more regional bands on the same server using docker compose install method, following the multi-regional example 1 in the docs:
https://www.chirpstack.io/docs/architecture.html?highlight=multi#multi-region-example-1

thank for the comment tho.

Its okay.
I use different subbands only changing gateway configuration (via UI).

Then put to work different devices, accordingly to the subband selected previously.

Hi @NicolasUy again i think you are mixing use-cases here. Where in V4 UI do you see ability to select gateway bands? I don’t see this option.
also if you look at the reference diagram here, you will see what I am trying to achieve.

regards

Hi Tom, sorry for misunderstanding.

I use putty and ssh into gateway and then configure it to work on any subband. The frequency band is always the same.

What I do is quite more easy than what you do. But, as you mentioned, they are different use cases.

Regards,

Nico

@brocaar currently I am unable to get a single instance of chirpstack (with docker compose) running 2-3 regions. Can you help with this? I hate having to spawn different servers for each region…

did you end up getting this working?

if not enable the regions you want like so…

chirpstack.toml

enabled_regions=[
    "as923",
    "as923_4"
  ]

this will load the region_as923.toml & region_as923_4.toml from the configuration/ folder, same place the chirpstack.toml is located. you will need to add the extra channels into the toml files for as923 - as without this it just uses the 2 join channels for all uplinks and downlinks. (currently i run 1 x as923 and 1 x au915 sb2 region).

now you need to create a seperate gateway bridge in your compose file for each of these regions you want to run. so now jump over into the chirpsack-gateway-bridge folder and create a regional toml for each region…

chirpstack-gateway-bridge-as923.toml

# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.

[integration.mqtt.auth.generic]
    servers=["tcp://mosquitto:1883"]
    username=""
    password=""

[integration.mqtt]
event_topic_template="as923/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
state_topic_template="as923/gateway/{{ .GatewayID }}/state/{{ .StateType }}"
command_topic_template="as923/gateway/{{ .GatewayID }}/command/#"

and

chirpstack-gateway-bridge-as923_4.toml

# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.

[integration.mqtt.auth.generic]
    servers=["tcp://mosquitto:1883"]
    username=""
    password=""

[integration.mqtt]
event_topic_template="as923_4/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
state_topic_template="as923_4/gateway/{{ .GatewayID }}/state/{{ .StateType }}"
command_topic_template="as923_4/gateway/{{ .GatewayID }}/command/#"

and your docker compose gateway bridge section should look something like this…

docker-compose.yml

  chirpstack-gateway-bridge-as923:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1921:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-as923.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on: 
      - mosquitto

  chirpstack-gateway-bridge-as923-4:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1924:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-as923_4.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on:
      - mosquitto

this should give you as923 bridge listening on udp port 1921 and as923_4 bridge listening on udp port 1924. i did this off memory, but i’m fairly confidant this should be all you need, let me know how you go with it - the only other thing i did was remove all the regions i dont run a gw bridge for from the configuration directory so it doesnt waste time trying to load them.

@ccall48 thanks for the detailed reply boss! I figure where my error was…

when I gave different ports for each bridge, I changed both remote and local ports isntead of just the exposed port

  chirpstack-gateway-bridge-as923-4:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1701:1701/udp

where it should be, like your example shows,


  chirpstack-gateway-bridge-as923-4:
    image: chirpstack/chirpstack-gateway-bridge:4.0.1
    restart: unless-stopped
    ports:
      - 1701:1700/udp

the rest I had configured correctly, and the enabled_regions flag has all regions enabled by default in the docker.

closing this finally :>

1 Like

I’ve been asked to post the docker-compose.yml with some multi-region settings so here it is:

version: "3"

services:
  chirpstack:
    image: chirpstack/chirpstack:latest
    command: -c /etc/chirpstack
    restart: unless-stopped
    volumes:
      - ./configuration/chirpstack:/etc/chirpstack
      - ./lorawan-devices:/opt/lorawan-devices
    depends_on:
      - postgres
      - mosquitto
      - redis
    environment:
      - MQTT_BROKER_HOST=mosquitto
      - REDIS_HOST=redis
      - POSTGRESQL_HOST=postgres
    ports:
      - 8080:8080

  chirpstack-gateway-bridge-as923:
    image: chirpstack/chirpstack-gateway-bridge:latest
    restart: unless-stopped
    ports:
      - 1700:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-as923.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on: 
      - mosquitto

  chirpstack-gateway-bridge-eu868:
    image: chirpstack/chirpstack-gateway-bridge:latest
    restart: unless-stopped
    ports:
      - 1702:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-eu868.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on:
      - mosquitto

  chirpstack-gateway-bridge-as923-4:
    image: chirpstack/chirpstack-gateway-bridge:latest
    restart: unless-stopped
    ports:
      - 1701:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-as923_4.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on:
      - mosquitto
  chirpstack-gateway-bridge-us915_0:
    image: chirpstack/chirpstack-gateway-bridge:latest
    restart: unless-stopped
    ports:
      - 1704:1700/udp
    volumes:
      - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
      - ./configuration/chirpstack-gateway-bridge/chirpstack-gateway-bridge-us915_0.toml:/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
    depends_on:
      - mosquitto
  chirpstack-rest-api:
    image: chirpstack/chirpstack-rest-api:latest
    restart: unless-stopped
    command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure
    ports:
      - 8090:8090
    depends_on:
      - chirpstack

  postgres:
    image: postgres:14-alpine
    restart: unless-stopped
    volumes:
      - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
      - postgresqldata:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=root

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - redisdata:/data

  mosquitto:
    image: eclipse-mosquitto:2
    restart: unless-stopped
    ports:
      - 1883:1883
    volumes: 
      - ./configuration/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf

volumes:
  postgresqldata:
  redisdata:

and the config folders looks like this

/chirpstack-docker/configuration/chirpstack-gateway-bridge$ ls
chirpstack-gateway-bridge-as923.toml    chirpstack-gateway-bridge-us915_0.toml
chirpstack-gateway-bridge-as923_4.toml  chirpstack-gateway-bridge.toml
chirpstack-gateway-bridge-eu868.toml

example of one of the config files

/chirpstack-docker/configuration/chirpstack-gateway-bridge$ cat chirpstack-gateway-bridge-as923.toml 
# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.

[integration.mqtt.auth.generic]
servers=["tcp://mosquitto:1883"]
username=""
password=""

[integration.mqtt]
event_topic_template="as923/gateway/{{ .GatewayID }}/event/{{ .EventType }}"
state_topic_template="as923/gateway/{{ .GatewayID }}/state/{{ .StateType }}"
command_topic_template="as923/gateway/{{ .GatewayID }}/command/#"

good luck!

3 Likes

Thanks for sharing! Tom!

it is worth mentioning, that your packet forwarder if you are using Semtech UDP protocol, needs to be set to the port set for that region

in my example, US915_0 gws needs to forward packets to port 1704 for both up/down

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.