While walking @ziegler1960 through the process of running the app, it became apparent that he would need various configurations of the .env file at any given time. Reasons for this include, but are not limited to…
Connecting to various Canvas instances
Authenticating to the Canvas API with various tokens (keys)
Working with various Canvas subaccounts
Working with various Canvas terms
Working with various LTI tools
Editing the .env file each time a different configuration is needed is very inconvenient.
A possible solution would be to keep various versions of .env around and copy the one needed into the main one before running the app. I.e., cp .env-special-config-1 .env. However, that can become awkward and easy to forget which configuration .env currently contains.
A better solution would be to include the name of the configuration file to be used as an argument to the app on the command line. I.e., the command python migration/main.py .env-special-config-1 would run the app which would read the specified config file instead of .env. If the app is run without an argument, then it would use the .env file by default, as it does now.
Update
Now that Docker compose is used to run the app, the best way to pass an argument via the command line would be to set a variable…
config=config_file_name docker compose up
And enabling that variable in the docker-compose.yaml (untested pseudocode)…
env:
config: ${config}
Then accessing that in the application… (The default config file name is now env, not .env.)
While walking @ziegler1960 through the process of running the app, it became apparent that he would need various configurations of the
.env
file at any given time. Reasons for this include, but are not limited to…Editing the
.env
file each time a different configuration is needed is very inconvenient.A possible solution would be to keep various versions of
.env
around and copy the one needed into the main one before running the app. I.e.,cp .env-special-config-1 .env
. However, that can become awkward and easy to forget which configuration.env
currently contains.A better solution would be to include the name of the configuration file to be used as an argument to the app on the command line. I.e., the command
python migration/main.py .env-special-config-1
would run the app which would read the specified config file instead of.env
. If the app is run without an argument, then it would use the.env
file by default, as it does now.Update
Now that Docker compose is used to run the app, the best way to pass an argument via the command line would be to set a variable…
And enabling that variable in the
docker-compose.yaml
(untested pseudocode)…Then accessing that in the application… (The default config file name is now
env
, not.env
.)