mirror of https://github.com/snachodog/mybuddy.git
Improve database setting configuration options (#182)
* Updated docker.py to allow for custom PSQL env input * Updated README.md with new PSQL env variables * Updated with new variable names and adjusted inline logic * Updated README.md to reflect new env variable names * Updated database password fallback to prevent breaking existing deployments * Updated with new env variables * Further edits per PR discussion * Removed unnecessary variables from example docker-compose file
This commit is contained in:
parent
b009a0bebc
commit
4733ec0b83
44
README.md
44
README.md
|
@ -283,6 +283,12 @@ take precedence over the contents of an `.env` file.**
|
|||
- [`DEBUG`](#debug)
|
||||
- [`NAP_START_MAX`](#nap_start_max)
|
||||
- [`NAP_START_MIN`](#nap_start_min)
|
||||
- [`DB_ENGINE`](#db_engine)
|
||||
- [`DB_HOST`](#db_host)
|
||||
- ['DB_NAME'](#db_name)
|
||||
- [`DB_PASSWORD`](#db_password)
|
||||
- [`DB_PORT`](#db_port)
|
||||
- [`DB_USER`](#db_user)
|
||||
- [`SECRET_KEY`](#secret_key)
|
||||
- [`TIME_ZONE`](#time_zone)
|
||||
- [`USE_24_HOUR_TIME_FORMAT`](#use_24_hour_time_format)
|
||||
|
@ -354,6 +360,44 @@ entry is consider a nap. Expects the 24-hour format %H:%M.
|
|||
The minimum *start* time (in the instance's time zone) after which a sleep
|
||||
entry is considered a nap. Expects the 24-hour format %H:%M.
|
||||
|
||||
### 'DB_ENGINE'
|
||||
|
||||
*Default: django.db.backends.postgresql*
|
||||
|
||||
The database engine utilized for the deployment.
|
||||
|
||||
See also [Django's documentation on the ENGINE setting](https://docs.djangoproject.com/en/3.0/ref/settings/#engine) .
|
||||
|
||||
### 'DB_HOST'
|
||||
|
||||
*Default: db*
|
||||
|
||||
The name of the database host for the deployment.
|
||||
|
||||
### 'DB_NAME'
|
||||
|
||||
*Default: postgres*
|
||||
|
||||
The name of the database table utilized for the deployment.
|
||||
|
||||
### 'DB_PASSWORD'
|
||||
|
||||
*No Default*
|
||||
|
||||
The password for the database user for the deployment. In the default example, this is the root PostgreSQL password.
|
||||
|
||||
### 'DB_PORT'
|
||||
|
||||
*Default: 5432*
|
||||
|
||||
The listening port for the database. The default port is 5432 for PostgreSQL.
|
||||
|
||||
### 'DB_USER'
|
||||
|
||||
*Default: postgres*
|
||||
|
||||
The database username utilized for the deployment.
|
||||
|
||||
### `SECRET_KEY`
|
||||
|
||||
*Default: None*
|
||||
|
|
|
@ -4,13 +4,14 @@ from .base import *
|
|||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
# Load settings from env file / variables with fallback defaults to support current psql deployment
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'postgres',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
|
||||
'HOST': 'db',
|
||||
'PORT': 5432,
|
||||
'ENGINE': os.getenv('DB_ENGINE') or 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': os.getenv('DB_NAME') or 'postgres',
|
||||
'USER': os.getenv('DB_USER') or 'postgres',
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD') or os.environ.get('POSTGRES_PASSWORD'),
|
||||
'HOST': os.getenv('DB_HOST') or 'db',
|
||||
'PORT': os.getenv('DB_PORT') or 5432,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
image: postgres:11 # pin postgres to a major version
|
||||
environment:
|
||||
- PGDATA=/db-data
|
||||
- POSTGRES_PASSWORD=postgres # has to correspond with POSTGRES_PASSWORD in APP
|
||||
- POSTGRES_PASSWORD=postgres # has to correspond with DB_PASSWORD in APP
|
||||
volumes:
|
||||
- db:/db-data:rw
|
||||
app:
|
||||
|
@ -12,10 +12,10 @@ services:
|
|||
# See README.md#configuration for other environment configuration options.
|
||||
environment:
|
||||
- ALLOWED_HOSTS=
|
||||
- DB_PASSWORD=postgres # has to correspond with POSTGRES_PASSWORD in DB
|
||||
- DJANGO_SETTINGS_MODULE=babybuddy.settings.docker
|
||||
- SECRET_KEY=
|
||||
- TIME_ZONE=
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- DEBUG=False # Turn to False in production
|
||||
volumes:
|
||||
- media:/app/media:rw
|
||||
|
|
Loading…
Reference in New Issue