Skip to content

About

Setup ChirpStack using Docker Compose

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

IOTOWN MQTT Bridge

Bridges device uplink messages from ChirpStack to IOTOWN MQTT server.

Configuration

Edit configuration/iotown-mqtt-bridge/config.yml:

# IOTOWN MQTT server settings
iotown:
  mqtt:
    host: host.docker.internal  # Host machine's localhost
    port: 8883
    username: bridge
    password: your_password
    rejectUnauthorized: false   # Allow self-signed certificates

# Application ID -> Group ID mapping
appGroupMapping:
  550e8400-e29b-41d4-a716-446655440000: 7f3d2a1e-8b4c-4d5f-9a6b-c8e7f0123456
  6ba7b810-9dad-11d1-80b4-00c04fd430c8: a1b2c3d4-e5f6-7890-abcd-ef1234567890

# Default group ID for unmapped applications (leave empty to not forward them)
defaultGroupId: 00000000-0000-0000-0000-000000000000

# Applications whose device uplinks are not forwarded to IOTOWN
# (e.g. the application holding EdgeEye virtual session devices)
excludeApplications:
  - 4ffa3b95-9424-4bf2-8d15-1ff02534ae37

# Log level: debug, info, warn, error
logLevel: info

Web UI

The bridge serves a web UI on port 8081 (plain HTTP, like the ChirpStack UI on 8080; set BRIDGE_WEB_PORT in .env to publish it on another host port) for editing config.yml without restarting:

  • Status: ChirpStack and IOTOWN MQTT connection state, message counters, recent errors
  • Mapping: application → IOTOWN group, excluded applications, gateway → group, downlink defaults (applied immediately)
  • Connections: ChirpStack (the one installed alongside, or an external server), IOTOWN address and bridge account, ChirpStack API key (changed connections reconnect)
  • Logs: the bridge log, live, and the logging level (what the bridge records)

The first login is admin / admin, and a new password is required before anything else. The password hash is stored in web-auth.json next to config.yml, so the configuration/iotown-mqtt-bridge directory must be writable by uid 1000 (the container's node user); the install.sh and update.sh of a build.sh package set this when run as root. Saving from the UI keeps the comments in config.yml.

The mapping page picks applications and gateways by name through the ChirpStack REST API, so an admin API key from ChirpStack (API keys) must be entered under Connections first. Set WEB_PORT=0 to turn the UI off.

Image versions

The external images (ChirpStack, Gateway Bridge, REST API, PostgreSQL, Redis, Mosquitto) are pinned to exact versions in docker-compose.yml, the only place their tags are written. build.sh packages those tags and, when Node.js is available, reports newer ones on Docker Hub (node scripts/check-images.mjs <image>...; skipped offline). To upgrade, change the tag in docker-compose.yml. ChirpStack migrates its database on startup; a new PostgreSQL major version needs a dump and restore.

Server-specific changes

Keep changes for one server out of docker-compose.yml, so it can be updated by git pull or by the update.sh of a build.sh package (which replaces it and keeps the old one as docker-compose.yml.backup.<time>):

  • Ports, extra mounts and other service changes go in docker-compose.override.yml next to it, which Docker Compose merges automatically (ports: !override replaces a service's ports instead of adding).
  • The bridge web UI's host port can also be set in .env, e.g. BRIDGE_WEB_PORT=8084.

Example, running a custom ChirpStack binary:

services:
  chirpstack:
    volumes:
      - ./bin_amd64/chirpstack:/usr/bin/chirpstack:ro

Topic Transformation

ChirpStack: application/{application_id}/device/{dev_eui}/event/up
     ↓
IOTOWN:     iotown/{group_id}/{device_id}/data
  • group_id: Mapped from application_id via appGroupMapping (falls back to defaultGroupId; not forwarded when that is empty)
  • Applications listed in excludeApplications are skipped entirely (nothing is published to IOTOWN)
  • device_id: Same as dev_eui

Usage

# Build and start
docker compose up -d iotown-mqtt-bridge

# View logs
docker compose logs -f iotown-mqtt-bridge

# Restart after config changes
docker compose restart iotown-mqtt-bridge

Host Machine Access

If IOTOWN server runs on the host machine, set host to host.docker.internal.


ChirpStack Docker example

This repository contains a skeleton to setup the ChirpStack open-source LoRaWAN Network Server (v4) using Docker Compose.

Note: Please use this docker-compose.yml file as a starting point for testing but keep in mind that for production usage it might need modifications.

Directory layout

  • docker-compose.yml: the docker-compose file containing the services
  • configuration/chirpstack: directory containing the ChirpStack configuration files
  • configuration/chirpstack-gateway-bridge: directory containing the ChirpStack Gateway Bridge configuration
  • configuration/mosquitto: directory containing the Mosquitto (MQTT broker) configuration
  • configuration/postgresql/initdb/: directory containing PostgreSQL initialization scripts

Configuration

This setup is pre-configured for all regions. You can either connect a ChirpStack Gateway Bridge instance (v3.14.0+) to the MQTT broker (port 1883) or connect a Semtech UDP Packet Forwarder. Please note that:

  • You must prefix the MQTT topic with the region. Please see the region configuration files in the configuration/chirpstack for a list of topic prefixes (e.g. eu868, us915_0, au915_0, as923_2, ...).
  • The protobuf marshaler is configured.

This setup also comes with two instances of the ChirpStack Gateway Bridge. One is configured to handle the Semtech UDP Packet Forwarder data (port 1700), the other is configured to handle the Basics Station protocol (port 3001). Both instances are by default configured for EU868 (using the eu868 MQTT topic prefix).

Reconfigure regions

ChirpStack has at least one configuration of each region enabled. You will find the list of enabled_regions in configuration/chirpstack/chirpstack.toml. Each entry in enabled_regions refers to the id that can be found in the region_XXX.toml file. This region_XXX.toml also contains a topic_prefix configuration which you need to configure the ChirpStack Gateway Bridge UDP instance (see below).

ChirpStack Gateway Bridge (UDP)

Within the docker-compose.yml file, you must replace the eu868 prefix in the INTEGRATION__..._TOPIC_TEMPLATE configuration with the MQTT topic_prefix of the region you would like to use (e.g. us915_0, au915_0, in865, ...).

ChirpStack Gateway Bridge (Basics Station)

Within the docker-compose.yml file, you must update the configuration file that the ChirpStack Gateway Bridge instance must used. The default is chirpstack-gateway-bridge-basicstation-eu868.toml. For available configuration files, please see the configuration/chirpstack-gateway-bridge directory.

Data persistence

PostgreSQL and Redis data is persisted in Docker volumes, see the docker-compose.yml volumes definition.

Requirements

Before using this docker-compose.yml file, make sure you have Docker installed.

Importing device repository

To import the lorawan-devices repository (optional step), run the following command:

make import-lorawan-devices

This will clone the lorawan-devices repository and execute the import command of ChirpStack. Please note that for this step you need to have the make command installed.

Note: an older snapshot of the lorawan-devices repository is cloned as the latest revision no longer contains a LICENSE file.

Usage

To start the ChirpStack simply run:

$ docker-compose up

After all the components have been initialized and started, you should be able to open http://localhost:8080/ in your browser.

The example includes the ChirpStack REST API. You should be able to access the UI by opening http://localhost:8090 in your browser.

Note: It is recommended to use the gRPC interface over the REST interface.

About

Setup ChirpStack using Docker Compose

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages