Use DATABASE_URL instead of POSTGRES_* in docker-compose.yml#22
Conversation
| image: postgres:latest | ||
| env: | ||
| POSTGRES_DB: postgres | ||
| POSTGRES_DB: test |
There was a problem hiding this comment.
Won't these new values break the database URL shown below?
There was a problem hiding this comment.
I'm changing these values to show that we can have different database names etc as long as we define DATABASE_URL (on line 37).
There was a problem hiding this comment.
(the github run-test action is still passing, which should indicate that this is working?)
|
If #26 is merged, I'll rebase this PR to work with the new github workflow. |
| DATABASES = { | ||
| # Can be overridden using DATABASE_URL | ||
| 'default': dj_database_url.config( | ||
| default='postgres://postgres:postgres@postgres:5432/postgres', |
There was a problem hiding this comment.
ahh I think we need to update this line to pull from the DATABASE_URL environment variable
There was a problem hiding this comment.
If you look at my commit message:
Instead we use the
dj_database_urlmodule, which takes a default url
but can be overridden by providing an environment variable called
DATABASE_URL.
It's built in to dj_database_url but it's new to me (and possibly a lot of other people) so I added a comment to tell people about DATABASE_URL.
There was a problem hiding this comment.
This simple Django utility allows you to utilize the 12factor inspired
DATABASE_URLenvironment variable to configure your Django application.
There was a problem hiding this comment.
Ahhh now I understand! Forgive my slowness and thank you for bearing with me :)
We had `POSTGRES_DB`, `POSTGRES_USER` and `POSTGRES_PASSWORD` in our `docker-compose.yml` but they are not actually used in the code. Instead we use the `dj_database_url` module, which takes a default url but can be overridden by providing an environment variable called `DATABASE_URL`. I changed the test database host, password and database name to show this works in the github test action.
| DATABASES = { | ||
| # Can be overridden using DATABASE_URL | ||
| 'default': dj_database_url.config( | ||
| default='postgres://postgres:postgres@postgres:5432/postgres', |
There was a problem hiding this comment.
Ahhh now I understand! Forgive my slowness and thank you for bearing with me :)

We had
POSTGRES_DB,POSTGRES_USERandPOSTGRES_PASSWORDin ourdocker-compose.ymlbut they are not actually used in the code.Instead we use the
dj_database_urlmodule, which takes a default urlbut can be overridden by providing an environment variable called
DATABASE_URL. I changed the test database host, password and databasename to show this works in the github test action.