DB environment variables

Also create the DB during a build

Hopefully I'm doing this right
This commit is contained in:
c0de 2018-03-08 20:36:41 -06:00
parent d08fb28c78
commit 2fb809b4e0
4 changed files with 22 additions and 4 deletions

View File

@ -9,6 +9,11 @@ jobs:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:2.7
environment:
POSTGRES_PASSWORD: totallyHacked1337
POSTGRES_USER: imagehost
POSTGRES_DB: imagehost_db
POSTGRES_HOST: localhost
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
@ -20,6 +25,13 @@ jobs:
steps:
- checkout
# Set up Test DB
- run: sudo apt install postgresql-client-9.4
- run: whoami
- run: |
psql < newdb.sql
# Download and cache dependencies
- restore_cache:
keys:

View File

@ -16,6 +16,10 @@ services:
build: .
environment:
PORTAL_DEBUG: 'true'
POSTGRES_PASSWORD: totallyHacked1337
POSTGRES_USER: imagehost
POSTGRES_DB: imagehost_db
POSTGRES_HOST: postgres
volumes:
- .:/portal
ports:

View File

@ -101,10 +101,10 @@ WSGI_APPLICATION = 'gallery.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'imagehost_db',
'USER': 'imagehost',
'PASSWORD': 'totallyHacked1337',
'HOST': 'postgres',
'NAME': os.environ.get('POSTGRES_DB', ''),
'USER': os.environ.get('POSTGRES_USER', 'root'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', ''),
'HOST': os.environ.get('POSTGRES_HOST', 'postgres').lower(),
'PORT': '',
}
}

2
newdb.sql Normal file
View File

@ -0,0 +1,2 @@
CREATE USER imagehost WITH SUPERUSER CREATEDB LOGIN PASSWORD 'totallyHacked1337';
CREATE DATABASE imagehost_db OWNER imagehost;