ChirpStack Docker Deployment

repository·master·Indexed 18 days ago

https://github.com/chirpstack/chirpstack-docker

A Docker Compose skeleton for deploying the ChirpStack v4 LoRaWAN Network Server. This setup includes integrated services such as Mosquitto (MQTT), PostgreSQL, Redis, and the ChirpStack Gateway Bridge. It provides configurations for various regions, support for UDP Packet Forwarder and Basics Station, and interfaces for the ChirpStack Web UI, REST API, and gRPC.

Tokens
2.4K
Snippets
9
Records
12
Agent score
13%

What's inside chirpstack-docker

  1. ChirpStack Docker Directory Layout

    master

    Understanding the project structure for configuration management:

    • docker-compose.yml: The main orchestration file for all services.
    • configuration/chirpstack: ChirpStack core configuration files (including region files).
    • configuration/chirpstack-gateway-bridge: Configuration for the ChirpStack Gateway Bridge.
    • configuration/mosquitto: Mosquitto MQTT broker configuration.
    • configuration/postgresql/initdb/: PostgreSQL initialization scripts.
  2. ChirpStack API Interfaces

    master

    ChirpStack provides two primary interfaces for interacting with the network server:

    1. gRPC Interface: Recommended for most programmatic integrations.
    2. REST API: Available via http://localhost:8090 in this Docker setup for testing and exploration.

    Refer to the official ChirpStack documentation for specific API schemas.

  3. Quickstart: Start ChirpStack with Docker Compose

    master

    To start the ChirpStack LoRaWAN Network Server (v4) stack, ensure you have Docker installed and run the following command from the repository root:

    docker compose up

    Once all components are initialized and running:

    • ChirpStack Web UI: Access at http://localhost:8080/
    • ChirpStack REST API UI: Access at http://localhost:8090

    Note: For production usage, this configuration may require modifications.

  4. Configure ChirpStack Regions

    master

    The setup is pre-configured for all regions. To use a specific region, you must manage two configuration points:

    1. Enable the region in ChirpStack

    Locate the enabled_regions list in configuration/chirpstack/chirpstack.toml. Each entry must match an id found in the corresponding region_XXX.toml file within the same directory.

    2. Configure the Gateway Bridge

    Depending on your gateway protocol, you must update the docker-compose.yml:

    • UDP Packet Forwarder: Replace the eu868 prefix in the INTEGRATION__..._TOPIC_TEMPLATE environment variable with the topic_prefix defined in your chosen region_XXX.toml (e.g., us915_0, au915_0).
    • Basics Station: Update the configuration file used by the ChirpStack Gateway Bridge instance in docker-compose.yml. The default is chirpstack-gateway-bridge-basicstation-eu868.toml. Available configurations are located in configuration/chirpstack-gateway-bridge/.
  5. Import ChirpStack Device Profiles

    master

    If you want to import the chirpstack-device-profiles repository to populate device profiles, run the following command. This requires make to be installed on your system. This step clones the repository and executes the ChirpStack import command.

    make import-device-profiles
  6. Configure ChirpStack Gateway Bridge Basicstation

    master

    The chirpstack-gateway-bridge-basicstation service is a specialized version of the gateway bridge designed for Basicstation-compatible gateways. It uses a specific configuration file (e.g., chirpstack-gateway-bridge-basicstation-eu868.toml) passed via the command flag.

    services:
      chirpstack-gateway-bridge-basicstation:
        image: chirpstack/chirpstack-gateway-bridge:4
        command: -c /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge-basicstation-eu868.toml
        ports:
          - "3001:3001"
        volumes:
          - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
  7. Configure Redis for ChirpStack

    master

    The redis service provides in-memory data storage.

    Configuration

    The service runs with the following command to manage persistence: redis-server --save 300 1 --save 60 100 --appendonly no

    Persistence

    Data is stored in the redisdata volume, mapped to /data inside the container.

    services:
      redis:
        image: redis:7-alpine
        command: redis-server --save 300 1 --save 60 100 --appendonly no
        volumes:
          - redisdata:/data
    
    volumes:
      redisdata:
  8. Configure Mosquitto MQTT Broker

    master

    The mosquitto service acts as the MQTT broker for the system.

    Configuration

    Configuration files are managed via a volume mount from ./configuration/mosquitto/config/ to /mosquitto/config/ inside the container.

    Ports

    • Port 1883 is exposed for MQTT communication.
    services:
      mosquitto:
        image: eclipse-mosquitto:2
        ports:
          - "1883:1883"
        volumes: 
          - ./configuration/mosquitto/config/:/mosquitto/config/
  9. Configure the ChirpStack REST API

    master

    The chirpstack-rest-api service provides a RESTful interface to the ChirpStack core.

    By default, it is configured with:

    • --server chirpstack:8080: Points to the ChirpStack core service.
    • --bind 0.0.0.0:8090: Binds the API to all interfaces on port 8090.
    • --insecure: Enables insecure communication (no TLS).

    It exposes port 8090 for external access.

    services:
      chirpstack-rest-api:
        image: chirpstack/chirpstack-rest-api:4
        command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure
        ports:
          - "8090:8090"
  10. Configure ChirpStack Gateway Bridge

    master

    The chirpstack-gateway-bridge service facilitates communication between gateways and the ChirpStack core via MQTT.

    MQTT Topic Templates

    You can customize the MQTT topic structure using these environment variables:

    • INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE: Template for gateway events.
    • INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE: Template for gateway state.
    • INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE: Template for gateway commands.

    Example templates used in the default configuration:

    • eu868/gateway/{{ .GatewayID }}/event/{{ .EventType }}
    • eu868/gateway/{{ .GatewayID }}/state/{{ .StateType }}
    • eu868/gateway/{{ .GatewayID }}/command/#
    services:
      chirpstack-gateway-bridge:
        image: chirpstack/chirpstack-gateway-bridge:4
        environment:
          - INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/event/{{ .EventType }}
          - INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/state/{{ .StateType }}
          - INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/command/#
        ports:
          - "1700:1700/udp"
        volumes:
          - ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
  11. Configure the ChirpStack core service

    master

    The chirpstack service runs the main ChirpStack application. It relies on PostgreSQL, Mosquitto (MQTT), and Redis. You can configure its connection parameters using the following environment variables:

    • MQTT_BROKER_HOST: The hostname of the MQTT broker (defaults to mosquitto in this setup).
    • REDIS_HOST: The hostname of the Redis instance (defaults to redis in this setup).
    • POSTGRESQL_HOST: The hostname of the PostgreSQL database (defaults to postgres in this setup).

    Configuration files are provided via a volume mount from ./configuration/chirpstack to /etc/chirpstack inside the container.

    services:
      chirpstack:
        image: chirpstack/chirpstack:4
        command: -c /etc/chirpstack
        environment:
          - MQTT_BROKER_HOST=mosquitto
          - REDIS_HOST=redis
          - POSTGRESQL_HOST=postgres
        volumes:
          - ./configuration/chirpstack:/etc/chirpstack
        ports:
          - "8080:8080"
  12. Configure PostgreSQL for ChirpStack

    master

    The postgres service provides the relational database for ChirpStack.

    Environment Variables

    • POSTGRES_USER: Database username (default: chirpstack).
    • POSTGRES_PASSWORD: Database password (default: chirpstack).
    • POSTGRES_DB: Database name (default: chirpstack).

    Persistence and Initialization

    • Initialization: Scripts in ./configuration/postgresql/initdb are executed during the first container startup via /docker-entrypoint-initdb.d.
    • Data Volume: Persistent data is stored in the postgresqldata volume, mapped to /var/lib/postgresql/data.
    services:
      postgres:
        image: postgres:14-alpine
        environment:
          - POSTGRES_USER=chirpstack
          - POSTGRES_PASSWORD=chirpstack
          - POSTGRES_DB=chirpstack
        volumes:
          - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
          - postgresqldata:/var/lib/postgresql/data
    
    volumes:
      postgresqldata: