diff --git a/configuration/chirpstack/chirpstack.toml b/configuration/chirpstack/chirpstack.toml index 54c3e5d..c225750 100644 --- a/configuration/chirpstack/chirpstack.toml +++ b/configuration/chirpstack/chirpstack.toml @@ -99,8 +99,13 @@ [integration] - enabled=["mqtt"] + enabled=["mqtt", "postgresql"] [integration.mqtt] server="tcp://$MQTT_BROKER_HOST:1883/" json=true + + [integration.postgresql] + dsn="postgres://chirpstack:chirpstack@localhost/chirpstack_integration?sslmode=disable" + + diff --git a/configuration/postgresql/initdb/003-init-integrationdb.sh b/configuration/postgresql/initdb/003-init-integrationdb.sh new file mode 100644 index 0000000..cbb1032 --- /dev/null +++ b/configuration/postgresql/initdb/003-init-integrationdb.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# PostgreSQL commands to create a new role and database for ChirpStack +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL + create role chirpstack with login password 'chirpstack'; + create database chirpstack_integration with owner chirpstack; +EOSQL diff --git a/docker-compose.yml b/docker-compose.yml index ca63658..ccadd09 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,6 +56,8 @@ services: postgres: image: postgres:14-alpine restart: unless-stopped + ports: + - 5432:5432 volumes: - ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d - postgresqldata:/var/lib/postgresql/data