Merge remote-tracking branch 'origin/feature-postgres' into develop

This commit is contained in:
Jan Tuomi
2017-05-10 19:37:18 +03:00
8 changed files with 38 additions and 41 deletions
+2 -2
View File
@@ -4,9 +4,9 @@ services:
build:
context: .
dockerfile: scripts/db/Dockerfile
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD=toor
- POSTGRES_PASSWORD=toor
- POSTGRES_USER=root
web:
build:
context: .
+14 -6
View File
@@ -1,4 +1,4 @@
import sys
import sys
import os
import time
import random
@@ -10,12 +10,13 @@ from django.conf import settings
django.setup()
#django related stuff should be imported below this
from members.models import Member, MemberRequest
from infoscreen.models import Rotation, ExternalImageInfoItem, InfoInstance
from misc.namegenerator import generate_names
MEMBERAMOUNT = 30
MEMBERREQUESTAMOUNT = 3
print ("""THIS SCRIPT WILL GENERATE DUMMY VALUES TO DATABASE
AND SHOULD __NEVER__ BE RUN ON PRODUCTION.
print ("""THIS SCRIPT WILL GENERATE DUMMY VALUES TO DATABASE
AND SHOULD __NEVER__ BE RUN ON PRODUCTION.
IF YOU ARE ON PRODUCTION ABORT (ctrl-c) IMMEDIATELY!!!!
CONTINUING IN 10 SECONDS""")
time.sleep(10)
@@ -36,6 +37,13 @@ for i in range(MEMBERAMOUNT):
AYY=ayy,
jas=jas)
for m in list(Member.objects.all())[:5]:
MemberRequest.objects.create(member=m)
i_item = ExternalImageInfoItem.objects.create(
name="Heavy",
url="https://i.imgur.com/XXSSqDG.gif"
)
rot = Rotation.objects.create(name="Demo")
inst = InfoInstance.objects.create(
rotation=rot,
item=i_item,
duration=20.0
)
+1 -1
View File
@@ -3,7 +3,6 @@ decorator==4.0.9
Django==1.9
ipython==4.2.0
ipython-genutils==0.1.0
mysqlclient==1.3.7
pexpect==4.1.0
pickleshare==0.7.2
ptyprocess==0.5.1
@@ -18,3 +17,4 @@ djangorestframework==3.5.3
coverage==4.3.4
django-nose==1.4.4
uWSGI==2.0.14
psycopg2==2.7.1
+9 -15
View File
@@ -28,30 +28,24 @@ fi
echo "Building db container..."
docker-compose -p "$PROJECT" build db || { echo "Failed to build db!"; exit 1; }
echo "Starting db container..."
docker-compose -p "$PROJECT" up -d db || { echo "Failed to start db container!"; exit 1; }
echo "Waiting 10 seconds..."
sleep 10
echo "Importing database settings..."
docker-compose -p "$PROJECT" exec -T db sh /db/install.sh || { echo "Failed to import database settings!"; exit 1; }
echo "Shutting down db container..."
docker-compose down db
docker-compose -p "$PROJECT" up -d db
echo "Copying settings..."
cp sikweb/settings-docker-sample.py sikweb/settings.py || { echo "Failed to copy settings!"; exit 1; }
cp -n sikweb/settings-docker-sample.py sikweb/settings.py || { echo "Failed to copy settings!"; exit 1; }
echo "Building web container..."
docker-compose -p "$PROJECT" build web
sleep 10
echo "Running manage.py commands..."
docker-compose -p "$PROJECT" run web python manage.py migrate --noinput || { echo "Failed to apply migrations!"; exit 1; }
docker-compose -p "$PROJECT" run web python manage.py createdefaultadmin || { echo "Failed to create default admin user."; }
echo "generating dummydata"
docker-compose -p "$PROJECT" run web python /code/misc/create_dummydata.py || { echo "Failed to create default admin user."; }
echo "Starting web container..."
docker-compose -p "$PROJECT" up -d web || { echo "Failed to start containers!"; exit 1; }
echo "Starting all containers..."
docker-compose -p "$PROJECT" up -d || { echo "Failed to start containers!"; exit 1; }
echo "Done."
+2 -5
View File
@@ -1,5 +1,2 @@
FROM mariadb:latest
RUN mkdir -p /db
WORKDIR /db
ADD scripts/db/init.sql /db/
ADD scripts/db/install.sh /db/
FROM postgres:9.6
COPY scripts/db/init.sql /docker-entrypoint-initdb.d/init.sql
+8 -7
View File
@@ -1,7 +1,8 @@
DROP USER IF EXISTS 'sik';
FLUSH PRIVILEGES;
CREATE USER 'sik'@'%' IDENTIFIED BY 'password123';
CREATE DATABASE IF NOT EXISTS sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON `sik\_%` . * TO 'sik'@'%' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'%';
DROP ROLE IF EXISTS sik;
CREATE USER sik WITH PASSWORD 'password123';
ALTER ROLE sik SET client_encoding TO 'utf8';
ALTER ROLE sik SET default_transaction_isolation TO 'read committed';
ALTER ROLE sik SET timezone TO 'UTC';
CREATE DATABASE sik
ENCODING 'UTF8'
OWNER sik;
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
set -e
mysql -u root -ptoor < /db/init.sql
+2 -2
View File
@@ -97,12 +97,12 @@ WSGI_APPLICATION = 'sikweb.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'sik',
'USER': 'sik',
'PASSWORD': 'password123',
'HOST': 'db',
'PORT': '3306',
'PORT': '5432',
'TEST': {
'NAME': 'sik_test',
},