2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Table of contents
3. Why choose Docker deployment?
3. Deployment process under Linux
4. Web interface deployment process
In this article, I use LinuxDockerDeploy chirpstack, chirpstack usesv4 version, v4 version and v3 Compared with Docker, gRPC API has made some changes, and compatibility needs to be considered. However, we only use Docker to deploy chirpstack. In fact, there are some changes in the directory and web interface. The configuration logic is the same, and there is not much change. If you are using the v3 version, you can ask me directly if you don’t understand anything.
ChirpStack is an open source LoRaWAN network server that can be used to set up private or public LoRaWAN networks. ChirpStack provides a web interface Used to manage gateways, devices, and applications.ChirpStack provides a gRPC-based API that can be used to integrate or extend ChirpStack.
(1)ChirpStack Network Server: NS for short, its function isEnsure the normal operation of the LoRaWAN network and manage device communications.ThatResponsible for the core logic of the LoRaWAN network. It handles the device joining process, downlink scheduling, device activity status tracking, etc. It is also responsible for processing the uplink data received from the LoRa gateway and sending the downlink data to the gateway.
(2)ChirpStack Application Server: referred to as AS, its function isManage and process application layer data, and provide user interface and API interface.ThatResponsible for processing and managing LoRaWAN application layer data. It allows users to define applications, device configurations, and data decoders. It also provides APIs and web interfaces for managing devices, monitoring network traffic, handling data decoding, and sending application layer data to external applications.
(3)ChirpStack Gateway Bridge:itActs as middleware between the gateway and the web serverThis component can convert the LoRa packet forwarder protocol transmitted from the LoRa gateway into the common data format (JSON and Protobuf) of the ChirpStack network server.
(4)PostgreSQL: This is an open source relational database management system forPersistent Storage ChirpStack configuration data, device information, gateway information, application data, etc.
(5)Redis: This is an open source in-memory data structure storage system, usuallyUsed as a database, cache, and message brokerChirpStack uses Redis to cache and process some real-time data to improve system performance and response speed.
(6)Mosquitto:Mosquitto is a MQTT protocol proxy server forHandles communication between devices and ChirpStack components.It allows messaging between LoRaWAN gateways and ChirpStack services.
Note the difference between Postgre SQL and Redis. Postgre SQL stores data on disk and supports persistent storage. Even if the system is restarted, the data will not be lost. The performance is relatively slow. Redis stores data on memory and supports efficient read and write operations, with extremely high performance.
(1) Simplify the deployment process:As mentioned above, ChirpStack is composed of multiple service components. Docker Compose allows us to use a configuration file (docker-compose.yml
) Define and run multiple containers with just one command (docker-compose up
) to start all services.
(2) Environmental isolation:Each chirpstack service can run in an independent container, avoiding dependency conflicts and environmental pollution.
(3) Portability:Using Docker, we can ensure that the same code and configuration are running in development, test, and production environments. This helps avoid "environment problems" that arise in different environments.
(4) Centralized configuration:All service configurations are centralized in one docker-compose.yml
file for easy management and version control. We can easily modify and update the configuration.
1. Pull the source code from github
v4 version: (The following will explain the v4 version)
git clone https://github.com/chirpstack/chirpstack-docker.git
v3 version:
git clone https://github.com/chirpstack/chirpstack-docker/tree/v3
2. Modificationdocker-compose.yml
Configuration Files
The file is aA multi-container application configured using Docker Compose for deploying the ChirpStack IoT platform.Covers all the major components required by the ChirpStack system, ensuring they work together in a Docker container. (Note that this configuration file usually only needs to modify the frequency band and port you want, and nothing else needs to be changed)
(1)chirpstack
This is the ChirpStack application server (usually no modification is required).
- chirpstack:
- image: chirpstack/chirpstack:4
- 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/chirpstack:4
Mirror image./etc/chirpstack
。unless-stopped
, that is, the container will automatically restart unless it is stopped manually../configuration/chirpstack
to the container/etc/chirpstack
,as well as ./lorawan-devices
to the container/opt/lorawan-devices
。postgres
, mosquitto
, redis
Three services.MQTT_BROKER_HOST
, REDIS_HOST
, POSTGRESQL_HOST
。8080
, the container 8080
Port mapping to the host8080
port.(2)chirpstack-gateway-bridge
This is the ChirpStack gateway bridge service (I use the cn470_10 band here).
- chirpstack-gateway-bridge:
- image: chirpstack/chirpstack-gateway-bridge:4
- restart: unless-stopped
- ports:
- - 1700:1700/udp
- volumes:
- - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
- environment:
- - INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=cn470_10/gateway/{{ .GatewayID }}/event/{{ .EventType }}
- - INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=cn470_10/gateway/{{ .GatewayID }}/state/{{ .StateType }}
- - INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=cn470_10/gateway/{{ .GatewayID }}/command/#
- depends_on:
- - mosquitto
unless-stopped
。1700
。./configuration/chirpstack-gateway-bridge
to the container/etc/chirpstack-gateway-bridge
。mosquitto
Serve.(3)chirpstack-gateway-bridge-basicstation
This is the basic station service of the ChirpStack gateway bridge (note the modification of the command part).
- chirpstack-gateway-bridge-basicstation:
- image: chirpstack/chirpstack-gateway-bridge:4
- restart: unless-stopped
- command: -c /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge-basicstation-cn470_10.toml
- ports:
- - 3001:3001
- volumes:
- - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
- depends_on:
- - mosquitto
chirpstack/chirpstack-gateway-bridge:4
Mirror image.unless-stopped
。chirpstack-gateway-bridge-basicstation-cn470_10.toml
。3001
。./configuration/chirpstack-gateway-bridge
to the container/etc/chirpstack-gateway-bridge
。mosquitto
Serve.(4)chirpstack-rest-api
This is ChirpStack's REST API service.
- chirpstack-rest-api:
- image: chirpstack/chirpstack-rest-api:4
- restart: unless-stopped
- command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure
- ports:
- - 8090:8090
- depends_on:
- - chirpstack
chirpstack/chirpstack-rest-api:4
Mirror image.unless-stopped
。chirpstack:8080
, the binding address is 0.0.0.0:8090
, and enable unsafe mode.8090
。chirpstack
Serve.(5)postgres
This is the PostgreSQL database service.
- 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
postgres:14-alpine
Mirror image.unless-stopped
。./configuration/postgresql/initdb
to the container/docker-entrypoint-initdb.d
, and mount Docker volumes postgresqldata
to the container/var/lib/postgresql/data
。POSTGRES_PASSWORD
forroot
。(6)redis
This is the Redis in-memory database service.
- redis:
- image: redis:7-alpine
- restart: unless-stopped
- command: redis-server --save 300 1 --save 60 100 --appendonly no
- volumes:
- - redisdata:/data
redis:7-alpine
Mirror image.unless-stopped
。redis-server
, and specify a save strategy.redisdata
to the container/data
。(7)mosquitto
This is the MQTT message broker service.
- mosquitto:
- image: eclipse-mosquitto:2
- restart: unless-stopped
- ports:
- - 1883:1883
- volumes:
- - ./configuration/mosquitto/config/:/mosquitto/config/
(8)Volumes
Define the data volume.
- volumes:
- postgresqldata:
- redisdata:
3. DocE-compose starts
sudo docker-compose up -d
1. Access chirpstack (IP): 8080, the default account and password is admin
2. Create a gateway
Next, give the gateway a name as usual, but remember the gateway ID, and modify the corresponding ID in the gateway configuration.
3. Add device files
Fill in according to your requirements.
4. Configure AS
After adding the Play app, add devices and multicast settings in the app one by one.
Finally, run the gateway to see if it can connect to the cloud server and forward messages successfully.