diff --git a/README.md b/README.md index e238c7f..6585920 100644 --- a/README.md +++ b/README.md @@ -92,4 +92,13 @@ The ``gamification/settings.py`` file contains installation-specific settings. T % python manage.py runserver +###Using the Docker container +1. You need to install [Docker](https://www.docker.com/) & + [composer](https://docs.docker.com/compose/): + +2. Spawn the containers: + + % docker-compose up + +3. Enjoy! diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..295331a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +web: + build: docker/web + hostname: web + volumes: + - .:/server + ports: + - "8000:8000" + links: + - db + environment: + - DJANGO_SETTINGS_MODULE=gamification.settings.docker +db: + image: postgres:9.4 + hostname: db + environment: + - POSTGRES_PASSWORD=postgres + ports: + - "5432:5432" diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile new file mode 100644 index 0000000..7fbc12d --- /dev/null +++ b/docker/web/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:14.04 +MAINTAINER Ariel Gerardo RĂ­os + +RUN ["mkdir", "/server"] +WORKDIR /server +VOLUME ["/server"] + +ENV DEBIAN_FRONTEND noninteractive + +RUN ["apt-get", "update"] +RUN ["apt-get", "install", "-y", "python-pip", "python-dev", "libpq-dev"] + +EXPOSE 8000 + +ENV DJANGO_SETTINGS_MODULE gamification.settings.docker +CMD ["/server/docker/web/entry_point.sh"] diff --git a/docker/web/entry_point.sh b/docker/web/entry_point.sh new file mode 100755 index 0000000..771fd3b --- /dev/null +++ b/docker/web/entry_point.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +WORKDIR="/server" + +cd $WORKDIR +pip install -r requirements.txt +python manage.py syncdb --noinput +python manage.py migrate +python manage.py runserver 0.0.0.0:8000 diff --git a/gamification/badges/migrations/0002_auto__add_field_projectbadge_awardLevel__add_field_projectbadge_multip.py b/gamification/badges/migrations/0002_auto__add_field_projectbadge_awardLevel__add_field_projectbadge_multip.py index 1da879e..e9d02a2 100644 --- a/gamification/badges/migrations/0002_auto__add_field_projectbadge_awardLevel__add_field_projectbadge_multip.py +++ b/gamification/badges/migrations/0002_auto__add_field_projectbadge_awardLevel__add_field_projectbadge_multip.py @@ -7,6 +7,10 @@ class Migration(SchemaMigration): + depends_on = ( + ("core", "0001_initial"), + ) + def forwards(self, orm): # Adding field 'ProjectBadge.awardLevel' db.add_column(u'badges_projectbadge', 'awardLevel', @@ -124,4 +128,4 @@ def backwards(self, orm): } } - complete_apps = ['badges'] \ No newline at end of file + complete_apps = ['badges'] diff --git a/gamification/settings/__init__.py b/gamification/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gamification/settings.py b/gamification/settings/base.py similarity index 91% rename from gamification/settings.py rename to gamification/settings/base.py index 74973c9..4dc6a2e 100644 --- a/gamification/settings.py +++ b/gamification/settings/base.py @@ -27,9 +27,15 @@ import os -PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) -PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) -SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) +PROJECT_ROOT = os.path.abspath(os.path.join( + os.path.dirname(__file__), os.pardir, os.pardir +)) + +PACKAGE_ROOT = os.path.abspath(os.path.join( + os.path.dirname(__file__), os.pardir +)) + +SITE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -40,17 +46,6 @@ MANAGERS = ADMINS -DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql_psycopg2", - "NAME": "gamification", - "USER": "game_manager", - "PASSWORD": "django-gamification", - "HOST": "", - "PORT": "5432" - } -} - # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. @@ -79,7 +74,7 @@ # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" -#MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media") +# MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media") # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. @@ -90,7 +85,7 @@ # Don"t put anything in this directory yourself; store your static files # in apps" "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" -#STATIC_ROOT = '{0}'.format('/var/www/static') +# STATIC_ROOT = '{0}'.format('/var/www/static') STATIC_ROOT = os.path.join(PACKAGE_ROOT, "static") MEDIA_ROOT = os.path.join(PROJECT_ROOT, "gamification/site_media") @@ -99,9 +94,9 @@ STATIC_URL = "/static/" # Additional locations of static files -#STATICFILES_DIRS = [ +# STATICFILES_DIRS = [ # os.path.join(PACKAGE_ROOT, "static"), -#] +# ] # List of finder classes that know how to find static files in # various locations. @@ -167,11 +162,11 @@ "django.contrib.sites", "django.contrib.messages", "django.contrib.staticfiles", - + # theme "pinax_theme_bootstrap", "django_forms_bootstrap", - + # external "account", "metron", @@ -181,7 +176,7 @@ "rest_framework", "corsheaders", "mptt", - + # project "gamification", "gamification.badges", @@ -237,9 +232,6 @@ "account.auth_backends.UsernameAuthenticationBackend", ] -CORS_ORIGIN_WHITELIST = ( '192.168.5.131:8000', 'localhost:8000', ) -CORS_ALLOW_METHODS = ( 'GET', 'POST', 'OPTIONS' ) - CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', diff --git a/gamification/settings/default.py b/gamification/settings/default.py new file mode 100644 index 0000000..6af707d --- /dev/null +++ b/gamification/settings/default.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Description: Settings for default environment. +""" + + +from base import * + + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql_psycopg2", + "NAME": "gamification", + "USER": "game_manager", + "PASSWORD": "django-gamification", + "HOST": "", + "PORT": "5432" + } +} + +CORS_ORIGIN_WHITELIST = ('192.168.5.131:8000', 'localhost:8000',) +CORS_ALLOW_METHODS = ('GET', 'POST', 'OPTIONS') diff --git a/gamification/settings/docker.py b/gamification/settings/docker.py new file mode 100644 index 0000000..8dcaa8d --- /dev/null +++ b/gamification/settings/docker.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Description: Settings for default environment. +""" + + +from base import * + + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql_psycopg2", + "NAME": "postgres", + "USER": "postgres", + "PASSWORD": "postgres", + "HOST": "db", + "PORT": "5432" + } +} + +CORS_ORIGIN_ALLOW_ALL = True diff --git a/manage.py b/manage.py index 14c9b5c..9d21ebe 100644 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import os, sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gamification.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gamification.settings.default") os.environ['PGCONNECT_TIMEOUT'] = '30' manage_dir = os.path.dirname(os.path.realpath(__file__)) diff --git a/requirements.txt b/requirements.txt index 3405e6e..238f347 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,13 @@ Django==1.5.4 Django-Select2==4.2.1 Intellect==1.4.9 +--allow-external PIL +--allow-unverified PIL PIL==1.1.7 Paver==1.2.1 South==0.8.2 +--allow-external antlr-python-runtime +--allow-unverified antlr-python-runtime antlr-python-runtime==3.1.3 django-appconf==0.6 django-bootstrap-toolkit==2.15.0