Environment variables for config

loraserver.toml is a pretty neat and easy config. Is there a way i can override the toml config so that specific values are injected as env variables directly onto the container since I am externalizing the data stores.

No, this is not possible.

On the 2.7.0 changelog for Lora Gateway Bridge, Lora Server, and Lora App server it has listed: " Environment variable based configuration has been re-implemented".

Does that mean that we can now use environment variables for configuration? I can’t find any documentation, but I would really like to be able to. Thanks.

It is documented, please see https://www.loraserver.io/lora-gateway-bridge/install/config/#environment-variables.

2 Likes

Apologies for being late to the thread, but thank you for continuing to support env variables. We are testing a deployment on Kubernetes, and the alternative configuration approaches are fairly onerous.

I’m trying to configure the lora-gateway-bridge using the following variables but it doesn’t seem to be referencing them.

bash/borne shell environment variables cannot contain a “dot” ‘.’ in it as the config documentation requires. Per shell convention, “dots” need to be replaced with ‘_’ (Underscores) and underscores with a double underscore

I get the following error:
ime=“2019-07-15T21:37:51Z” level=error msg=“could not setup mqtt backend, retry in 2 seconds: Network Error : dial tcp 127.0.0.1:1883: connect: connection refused”
time=“2019-07-15T21:37:53Z” level=info msg=“backend: TLS config is empty”
time=“2019-07-15T21:37:53Z” level=info msg=“backend: connecting to mqtt broker” server=“tcp://127.0.0.1:1883”

Ok after running a strings command on the lora-gateway-bridge binary i found an undocumented environment variable MQTT_SERVER :). I set it to my MQTT server and it worked. So is the configuration documentation wrong?

Hey @Haim_L,

How did you find the undocumented variables? I want to configure a subset of my app-server configuration using env_variables.

Thanks for your time!

Hey @brocaar,

Where can we find a full set of the enviromental variables? dot notation doesn’t work indeed.

You shouldn’t need any of the deprecated (“undocumented”) variables, almost every non-array variable matches up to its TOML grouping.

Which ones are you missing? The loraserver-docker repo has a good example for getting started with ENV-only configuration:

1 Like

I struggled with this for awhile until I figured it out. Those variables only work with docker-compose. They do not work using straight docker because bash/sh doesn’t support env vars with a ‘.’ in them

Hey everyone,

I think @Haim_L is correct, because when I run this script:

LORANK_IP=$(ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null root@172.18.0.1 -p22222 "nslookup lorank8.local" | grep "192" | awk '{print $3}')
export LORANK_IP
echo "LORANK IP is: ${LORANK_IP}"

POSTGRESQL.DSN="postgres://loraserver_as:loraserver_as@${LORANK_IP}:5432/loraserver_as?sslmode=disable"
REDIS.URL="redis//${LORANK_IP}:6379"
export POSTGRESQL.DSN
export REDIS.URL

APPLICATION_SERVER.INTEGRATION.MQTT.SERVER="tcp://${LORANK_IP}:1883"
export APPLICATION_SERVER.INTEGRATION.MQTT.SERVER

APPLICATION_SERVER.API.PUBLIC_HOST="${LORANK_IP}:8001"
export APPLICATION_SERVER.API.PUBLIC_HOST

echo "ENV_VARIABLES: \n ${POSTGRESQL.DSN}, ${REDIS.URL}, ${APPLICATION_SERVER.API.PUBLIC_HOST}, ${APPLICATION_SERVER.API.PUBLIC_HOST}, ${APPLICATION_SERVER.INTEGRATION.MQTT.SERVER}"
lora-app-server

I get all sorts of errors:

odys-macbook:lora_appserver Odys$ ./init_lora-app-server.sh
LORANK IP is: 192.168.1.64
./init_lora-app-server.sh: line 8: POSTGRESQL.DSN=postgres://loraserver_as:loraserver_as@192.168.1.64:5432/loraserver_as?sslmode=disable: No such file or directory
./init_lora-app-server.sh: line 9: REDIS.URL=redis//192.168.1.64:6379: No such file or directory
./init_lora-app-server.sh: line 10: export: `POSTGRESQL.DSN': not a valid identifier
./init_lora-app-server.sh: line 11: export: `REDIS.URL': not a valid identifier
./init_lora-app-server.sh: line 13: APPLICATION_SERVER.INTEGRATION.MQTT.SERVER=tcp://192.168.1.64:1883: No such file or directory
./init_lora-app-server.sh: line 14: export: `APPLICATION_SERVER.INTEGRATION.MQTT.SERVER': not a valid identifier
./init_lora-app-server.sh: line 16: APPLICATION_SERVER.API.PUBLIC_HOST=192.168.1.64:8001: command not found
./init_lora-app-server.sh: line 17: export: `APPLICATION_SERVER.API.PUBLIC_HOST': not a valid identifier
./init_lora-app-server.sh: line 19: ENV_VARIABLES: \n ${POSTGRESQL.DSN}, ${REDIS.URL}, ${APPLICATION_SERVER.API.PUBLIC_HOST}, ${APPLICATION_SERVER.API.PUBLIC_HOST}, ${APPLICATION_SERVER.INTEGRATION.MQTT.SERVER}: bad substitution

Is there any way to make it work without having to monkey patch a python script which will run gather the env_variables that I need and then create the toml file before starting app-server?

It is very important, because I run a distributed architecture and I need it to work with different networks.

Thanks everyone for your time :slight_smile:

This is a wide spread problem among many docker projects. They have resolved the issue by replacing ‘.’ with ‘__’ (double underscore). Until the lora code is modified to support this convention, there is nothing to be done other than to use docker-compose.

What is the notation for an array in docker compose environment variables. e.g. if you want to set APPLICATION_SERVER__INTEGRATION__ENABLED to `amqp?

In toml it lokks like:

  [application_server.integration]
  enabled=["mqtt"]

How does it look in a compose file?