We know Open edX is monolithic and we have some workarounds to run it in a container. When we build a container in a CI/CD pipeline, the best practices (The Twelve Factors) say to avoid store config as constants in the code.
An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc). This includes:
- Resource handles to the database, Memcached, and other backing services
- Credentials to external services such as Amazon S3 or Twitter
- Per-deploy values such as the canonical hostname for the deploy
Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.
Tutor saves all configuration to the files:
config/cms-env.json
config/lms-env.json
settings/cms/production.py
settings/lms/production.py
With this, we need to create secrets every build to store the files that have sensitive information and end up with many secret versions (cms-env-{COMMIT_HASH_1}, cms-env-v{COMMIT_HASH_2} …).
I think if we have an option to generate a setting file getting the values that can be changed between environments from the system environment variables would be a good feature.
We can have after tutor config save
command just production.py
file with something like this:
# json env files settings
SITE_NAME = os.getenv('SITE_NAME')
...
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"HOST": os.getenv('MYSQL_HOST'),
"PORT": os.getenv('MYSQL_PORT'),
"NAME": os.getenv('MYSQL_NAME'),
"USER": os.getenv('MYSQL_USER'),
"PASSWORD": os.getenv('MYSQL_PASSWORD'),
"ATOMIC_REQUESTS": true,
"OPTIONS": {
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'"
}
}
}
...
# python settings file settings
mongodb_parameters = {
"host": os.getenv('MONGO_USER'),
"port": os.getenv('MONGO_USER'),
"user": os.getenv('MONGO_USER'),
"password": os.getenv('MONGO_USER'),
"db": os.getenv('MONGO_USER'),
}
...
What do you think about it?