From c74e058e75eacd3bf46fa8e5a6f54f0a3f8c2341 Mon Sep 17 00:00:00 2001 From: David Wilby Date: Thu, 30 Sep 2021 18:22:01 +0100 Subject: [PATCH] add postgres db for staging and production --- annotation_tool/settings/production.py | 16 ++- annotation_tool/settings/staging.py | 13 +- create-django-db.sh | 10 ++ db-migrate.sh | 7 + docker-compose.yml | 45 ++++--- environment.yml | 175 +++++++++++++++++++++++-- 6 files changed, 231 insertions(+), 35 deletions(-) create mode 100755 create-django-db.sh create mode 100755 db-migrate.sh diff --git a/annotation_tool/settings/production.py b/annotation_tool/settings/production.py index 497c96c6..4609d345 100644 --- a/annotation_tool/settings/production.py +++ b/annotation_tool/settings/production.py @@ -1,5 +1,9 @@ +<<<<<<< HEAD import logging import sys +======= +import os +>>>>>>> add postgres db for staging and production from .base import * # Enable csrf in production @@ -33,4 +37,14 @@ 'propagate': True, }, }, -} \ No newline at end of file +} +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get("DJANGO_DB_NAME", "annotations_db"), + "USER": os.environ.get("DB_USERNAME", "user"), + "PASSWORD": os.environ.get("DB_PASSWORD", "password"), + "HOST": os.environ.get("DB_HOST", "db"), + "PORT": os.environ.get("DB_PORT", "5432"), + } +} diff --git a/annotation_tool/settings/staging.py b/annotation_tool/settings/staging.py index fd12fd10..2c88a493 100644 --- a/annotation_tool/settings/staging.py +++ b/annotation_tool/settings/staging.py @@ -1,3 +1,4 @@ +import os from .base import * # Enable csrf in production @@ -30,4 +31,14 @@ 'propagate': True, }, }, -} \ No newline at end of file +} +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': os.environ.get("DJANGO_DB_NAME", "annotations_db"), + "USER": os.environ.get("DB_USERNAME", "user"), + "PASSWORD": os.environ.get("DB_PASSWORD", "password"), + "HOST": os.environ.get("DB_HOST", "db"), + "PORT": os.environ.get("DB_PORT", "5432"), + } +} diff --git a/create-django-db.sh b/create-django-db.sh new file mode 100755 index 00000000..cc844252 --- /dev/null +++ b/create-django-db.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <