Closed jonespm closed 3 years ago
So here would be the steps for making this happen (in a bit more detail), based on the current status of the project:
1) Add a mysql
service to docker-compose
.
environment
settings are at the bottom).2) Add a configuration approach.
environment
or env_file
blocks in the docker-compose.yml
under the application service. Documentation for those blocks is here and here. I would start by using a .env
file that you include in a .gitignore
and .dockerignore
so that it isn't committed to the project or included in Docker images (see the docs here). You can include .env.sample
file in the repository with the variable names and some recommended values (so long as they aren't sensitive).os.getenv('SOME_VARIABLE', 'SOME_DEFAULT')
throughout the Python project (see the Python docs for the os
module). You can talk with @jonespm or me more later about optimizing configuration (which is a whole thing).3) Set up the database connection in Django.
sqlite
database is the default, and is currently managed here. The link there will take you to the specifics on adding the mysql
database connection. You can also add look at the Placement Exams example here (which is pretty straightforward, you can ignore the test stuff now).
Will need to switch the Docker Compose and the Django settings.
Example where we are doing this: https://github.com/tl-its-umich-edu/my-learning-analytics/blob/master/docker-compose.yml