Load Postgres parameters from the environment so that it can work with GitLab CI

This commit is contained in:
Danielle McLean 2018-06-04 09:32:47 +10:00
parent f7fbf49e1e
commit 4c0be4ce8b
2 changed files with 11 additions and 2 deletions

View file

@ -1,8 +1,14 @@
image: python:3.6 image: python:3.6
services:
- postgres:latest
variables: variables:
GIT_SUBMODULE_STRATEGY: normal GIT_SUBMODULE_STRATEGY: normal
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
PIPENV_CACHE_DIR: $CI_PROJECT_DIR/.cache/pipenv PIPENV_CACHE_DIR: $CI_PROJECT_DIR/.cache/pipenv
POSTGRES_HOST: postgres
POSTGRES_DB: nice_marmot
POSTGRES_USER: runner
POSTGRES_PASSWORD: ''
cache: cache:
paths: paths:

View file

@ -10,7 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
from os import path from os import environ, path
from typing import List from typing import List
APPEND_SLASH = False APPEND_SLASH = False
@ -170,7 +170,10 @@ CACHES = {
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'lemoncurry', 'NAME': environ.get('POSTGRES_DB', 'lemoncurry'),
'USER': environ.get('POSTGRES_USER'),
'PASSWORD': environ.get('POSTGRES_PASSWORD'),
'HOST': environ.get('POSTGRES_HOST', 'localhost'),
'CONN_MAX_AGE': 3600 'CONN_MAX_AGE': 3600
} }
} }