From 4c0be4ce8b7b2c80ebf28661a7f3b0f5594efe8e Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 4 Jun 2018 09:32:47 +1000 Subject: [PATCH] Load Postgres parameters from the environment so that it can work with GitLab CI --- .gitlab-ci.yml | 6 ++++++ lemoncurry/settings/base.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ed2cf5..05a0d31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,14 @@ image: python:3.6 +services: + - postgres:latest variables: GIT_SUBMODULE_STRATEGY: normal PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip PIPENV_CACHE_DIR: $CI_PROJECT_DIR/.cache/pipenv + POSTGRES_HOST: postgres + POSTGRES_DB: nice_marmot + POSTGRES_USER: runner + POSTGRES_PASSWORD: '' cache: paths: diff --git a/lemoncurry/settings/base.py b/lemoncurry/settings/base.py index 25a4bd2..911f2b2 100644 --- a/lemoncurry/settings/base.py +++ b/lemoncurry/settings/base.py @@ -10,7 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ -from os import path +from os import environ, path from typing import List APPEND_SLASH = False @@ -170,7 +170,10 @@ CACHES = { DATABASES = { 'default': { '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 } }