Set Constants thanks to Environment variables

0
Hello I use docker-mendix-buildpack to create a Docker image of my Mendix application. I use the OIDC module from the marketplace, which has a constants OIDC.ClientID. I set a default value for this constant, in the "Default" configuration. To test, I log the value of this constants, and I can see the correct default value in my logs, when I run my application locally from the Mendix Studio.   INFO - OIDC: !!!!!!!CLIENTID=XXXXXXXXXXXXXX     But when I run my Mendix app as a Docker Container, and I set this constant value thanks to an environment variable, as explained in docker-mendix-buildpack documentation, the value is empty.   INFO - OIDC: !!!!!!!CLIENTID=   The name of my environment variable is MX_OIDC_CLIENTID, and I don't even see the value set in the Default configuration... Did anyone manged to inject a value to a module constant thanks to an environment variable?
asked
1 answers
2

I finally found the solution, and I feel ashamed to inform you that it was caused by the case I used for my environment variables. Indeed, the mendix build pack is very case sensitive.

 

Anyway, I share my experience of my journey, with the exemple of the constant EncryptionKey from the markeplace module Encryption (Encryption.EncryptionKey) :

- the environment variable must be MX_Encryption_EncryptionKey (not fully uppercase as I did)

- inject it in your docker run command or in your docker-compose file

- when the container starts, the script runtime.py (from cf-mendix-buildpack used by docker-mendix-buildpack) turns the environment variables starting with MX_ prefix, into Mendix Constants.

- a very convenient way to debug is to run your docker container with the environment variable BUILDPACK_XTRACE set to true. You will see the environment variables you set and the Mendix constants computed values in the DEBUG traces at startup.

 

I hope it will help someone!

answered