Setup Postgres in a Docker Container
To setup a project with a postgres database container, add a service to a new or existing docker-compose.yml file in the project codebase, and add the following code:
services:
db:
image: postgres:12
ports:
- "5432:5432"
environment:
- "POSTGRES_HOST_AUTH_METHOD=trust"
- "POSTGRES_DB=${POSTGRES_DATABASE_NAME}"
- "POSTGRES_USER=${POSTGRES_DATABASE_USER}"
- "POSTGRES_PASSWORD=${POSTGRES_DATABASE_PASSWORD}"