tl-its-umich-edu / tool-migration

App for migrating external (LTI) tools in Instructure's Canvas LMS.
1 stars 3 forks source link

support multiple `.env` files #16

Closed lsloan closed 1 year ago

lsloan commented 1 year ago

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…

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.)

configFileName = os.env.get('config', 'env')
lsloan commented 1 year ago

For now, working on reduced functionality of this issue: Changing default config file name from .env to env.