env variables do not get loaded/used

Ralf2 years ago

I'm using traccar in a kubernetes cluster, where configuration is done trough env variables, however it seems like traccar doesn't pick them up properly, when I go into the container shell I see all the config that I've set, but it's not used in traccar itself. Am I doing something wrong, might this be a bug and is there a way to fix it?

Anton Tananaev2 years ago

Are you planning to provide more details on what you configured and what's not working?

Ralf2 years ago

Sure, I mean, here, a screenshot of how I made the env part in my config
https://cdn.discordapp.com/attachments/1152566501300244490/1152566715448836176/image.png

and if I go into the container shell and enter env I get something like this:

/opt/traccar $ env
DATABASE_USER=traccar
CONFIG_USE_ENVIRONMENT_VARIABLES=true
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://172.17.0.1:443
WEB_URL=https://traccar.mydomain.net
DATABASE_URL=databaseurl
HOSTNAME=traccar-...
TRACCAR_VERSION=5.3
SHLVL=1
OPENID_ISSUER_URL=https://authelia.mydomain.net/

(not showing everything because secret etc. is there, if any specific variables are required just tell me)

Anton Tananaev2 years ago

So what is not working?

Ralf2 years ago

Oh, and here the traccar.xml file:

/opt/traccar $ cat conf/traccar.xml
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key='config.default'>./conf/default.xml</entry>

    <!--

    This is the main configuration file. All your configuration parameters should be placed in this file.

    Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
    with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
    remove "config.default" parameter from this file unless you know what you are doing.

    For list of available parameters see following page: https://www.traccar.org/configuration-file/

    -->

    <entry key='database.driver'>org.h2.Driver</entry>
    <entry key='database.url'>jdbc:h2:./data/database</entry>
    <entry key='database.user'>sa</entry>
    <entry key='database.password'></entry>

</properties>

So as you see nothing from the env variables (for example openid_issuer_url) is written into this file.

Sorry for taking so long to answer, bad internet is an issue for some of us (I was moving trough a place with bad coverage)

Anton Tananaev2 years ago

Why do you expect something to be written in this file?

Ralf2 years ago

As you see I've made some enviroment variables, for example force openid connect from the screenshot or OPENID_ISSUER, which is visible in the part of env that I've copied here, that doesnt show any effect on traccar when I go to the portal, like the config wasn't changed and it also doesn't show up in the traccar.xml file, where these configs should be afaik

Ralf2 years ago

Because using env for configuration is more or less a standard way to do configuration in docker etc? I mean, I'm not an expert or anything, the way I understood is just env files are used because changing the files in the container directly can result in errors because updates could change stuff in there and changes u do as an user could prevent those changes from happening, so instead there is env, where u write ur config, and the container gets it from there and puts it whereever it's supposed to be ^^"

Anton Tananaev2 years ago

I understand why you want to use environment variables. That's not my question. My question is why you expect them to be written in the config file. Traccar never writes anything in the config. It will just use those variables directly.

Ralf2 years ago

Ah, ok, so I misunderstood you, however then my problem is that something with using those variables directly doesn't work, I mean I put OPENID_FORCE=true however the Login with OPENID Button doesnt even show up.

Ralf2 years ago

Do I have to do something else to activate OpenID?

Anton Tananaev2 years ago
Ralf2 years ago

That's what I followed