-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify db docker service to use the env file #437
base: main
Are you sure you want to change the base?
Conversation
2cc0bd9
to
5e12156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
I slack messaged Ethan about the sqlite. I think we need to wait for his response to determine how to name the env variables. But, ultimately, we want to get rid of the docker-compose.yml
variables like you did here.
app/.env.docker-example
Outdated
POSTGRES_ENGINE=django.db.backends.postgresql | ||
POSTGRES_DATABASE=people_depot_dev | ||
POSTGRES_USER=people_depot | ||
POSTGRES_PASSWORD=people_depot | ||
POSTGRES_HOST=db | ||
POSTGRES_PORT=5432 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there are other places with the "SQL_ENGINE" type of names. You should change them as well. They're commented out, but they're also examples for non-default cases.
This relates to what I said about whether or not changing the variable names make sense. I think if we're not going to run the backend with sqlite anymore, changing the name makes sense. If we want to continue making the backend work with sqlite, then maybe it doesn't make sense to change the variable names to have the "POSTGRES_" prefix. In that case, you can add the "POSTGRES-*" variables and do something like "SQL_USER=$POSTGRES_USER".
app/.env.docker-example
Outdated
SQL_HOST=db | ||
SQL_PORT=5432 | ||
POSTGRES_ENGINE=django.db.backends.postgresql | ||
POSTGRES_DATABASE=people_depot_dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the variable name is actually POSTGRES_DB, from the docker-compose.yml
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I wasn't more clear before. I was also not thinking clearly about the scope of this issue. We're just trying to remove the hardcoded lines in the compose file. Since the project had support for sqlite, we should just let it keep doing that and add a workaround to do both. I wrote the details on what to do in the comments.
SQL_PASSWORD=people_depot | ||
SQL_HOST=db | ||
SQL_PORT=5432 | ||
POSTGRES_ENGINE=django.db.backends.postgresql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the compose file only used POSTGRES USER, PASSWORD, and DB, you should just modify those 3 variable names.
I was trying to decide the best way to do this, and thinking what if we removed sqlite support to use postgres variable names only. But that's not the goal of this issue, so we should leave the code in a state where sqlite should still work.
This means that we still need to have the SQL USER, PASSWORD, and DATABASE variables since it wouldn't make sense for the sqlite section to assign to variables like POSTGRES_USER. To work around this, we can add assignments in this format for the 3 changed variables:
SQL_USER=POSTGRES_USER
...
Now we're limiting the changes to the docker section of the file and can leave the rest alone.
Please revert the changes to the local development section. I didn't give you clear enough instructions before for that, and I wasn't thinking right in terms of what this issue should be about.
@@ -116,8 +116,8 @@ | |||
|
|||
DATABASES = { | |||
"default": { | |||
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"), | |||
"NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"), | |||
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.postgresql"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes to this file. We don't really want to change the behavior of defaulting to sqlite.
Just a note to clarify how these lines work: Notice the first arguments to these os.environ.get
functions correspond to the env variable names in the .env.docker.example
file. Those would've needed to change to something like "POSTGRES_USER" if we were to switch everything to the postgres variable names. The 2nd arguments are the default values to return in case those variables are not present.
Fixes #309
What changes did you make?
docker-compose.yml
file to.env.docker-example
env_file: - ./app/.env.docker-example
indocker-compose.yml
settings.py
) code to use the database variable names that the db container usesWhy did you make the changes (we will use this info to test)?
docker-compose.yml
file