chirpstack / chirpstack-docker

Setup ChirpStack using Docker Compose
https://www.chirpstack.io/
MIT License
273 stars 316 forks source link

chirpstack-gateway-bridge environment variables #71

Closed ccall48 closed 1 year ago

ccall48 commented 1 year ago

Is is possible to build the official docker chirpstack-gateway-bridge image with ability to pass in environment variables? At the moment I have to hard card the mqtt username/password into the config file, it would be handy if something like below would work.

environment:
      - MQTT_USERNAME=${MQTT_USER}
      - MQTT_PASSWORD=${MQTT_PASS}

Whereas with the ChirpStack container I am able to pass in my own environment variables, which is very handy for config settings in the toml files, example bellow.

environment:
      - MQTT_BROKER_HOST=mosquitto
      - MQTT_USERNAME=${MQTT_USER}
      - MQTT_PASSWORD=${MQTT_PASS}
      - REDIS_HOST=${REDIS_HOST}
      - POSTGRESQL_HOST=${POSTGRESQL_HOST}
      - CHIRPSTACK_SECRET=${CHIRPSTACK_SECRET}
Sheng2216 commented 1 year ago

any updates regarding this issue? Did you ever get this solved? Thank you!

ccall48 commented 1 year ago

not yet that i'm aware of anyway.

brocaar commented 1 year ago

This is possible, but not in the same way as the ChirpStack configuration. Please see this configuration section: https://www.chirpstack.io/docs/chirpstack-gateway-bridge/configuration.html#environment-variables

ccall48 commented 1 year ago

This is possible, but not in the same way as the ChirpStack configuration. Please see this configuration section: https://www.chirpstack.io/docs/chirpstack-gateway-bridge/configuration.html#environment-variables

Hey mate, is there a specific environment variable key name i need to use? i've tried adding them with and without double underscores and nothing seems to work for me so far.

looking at the docs you linked i thought something like this might of worked.

environment:
      - INTEGRATION__MQTT__AUTH__GENERIC_SERVERS=mosquitto
      - INTEGRATION__MQTT__AUTH__GENERIC_USERNAME=${MQTT_USER}
      - INTEGRATION__MQTT__AUTH__GENERIC_PASSWORD=${MQTT_PASS}

which results in it looking for broker at localhost

time="2023-02-11T16:42:35.223633903+11:00" level=error msg="[client]   dial tcp 127.0.0.1:1883: connect: connection refused" module=mqtt
time="2023-02-11T16:42:35.223669154+11:00" level=warning msg="[client]   failed to connect to broker, trying next" module=mqtt
time="2023-02-11T16:42:35.223682635+11:00" level=error msg="[client]   Failed to connect to a broker" module=mqtt
time="2023-02-11T16:42:35.223727396+11:00" level=error msg="integration/mqtt: connection error" error="network Error : dial tcp 127.0.0.1:1883: connect: connection refused"

If i hard code the server in gateway bridge toml to see if user/pass are being passed (which checking docker-compose config is says they are) I get auth error as my environment variable key names must be incorrect - but i dont know what to call them.

time="2023-02-11T16:47:00.422691748+11:00" level=error msg="[client]   Connecting to tcp://mosquitto:1883 CONNACK was not CONN_ACCEPTED, but rather Connection Refused: Not Authorised" module=mqtt
time="2023-02-11T16:47:00.4234238+11:00" level=error msg="[client]   Failed to connect to a broker" module=mqtt
time="2023-02-11T16:47:00.423676469+11:00" level=error msg="integration/mqtt: connection error" error="not Authorized"
brocaar commented 1 year ago

INTEGRATION__MQTT__AUTH__GENERIC_SERVERS you are missing one _ after GENERIC_, it should be GENERIC__SERVERS.

E.g. INTEGRATION__MQTT__AUTH__GENERIC__SERVERS=tcp://foobar:1883