I am using django-environ package for my Django project.
I provided the DB url in the .env file, which looks like this:
DATABASE_URL=psql://dbuser:dbpassword@dbhost:dbport/dbname
My DB settings in settings.py:
DATABASES = {
"default": env.db(),
}
So far, I have no issues.
Then, I created a docker-compose.yml where I specified that my project uses Postgres database, i.e.:
version: '3.8'
services:
...
db
image: postgres:13
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=???
- POSTGRES_PASSWORD=???
- POSTGRES_DB=???
- "POSTGRES_HOST_AUTH_METHOD=trust"
Now I am confused a little.
How do I provide these POSTGRES_* env. variables there? Do I need to provide them as separate variables alongside with the DATABASE_URL in my .env file? If yes, what's the best way do accomplish this? I aim to avoid duplication in my settings.