Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:14.04
MAINTAINER Ariel Gerardo Ríos <[email protected]>

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"]
9 changes: 9 additions & 0 deletions docker/web/entry_point.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -124,4 +128,4 @@ def backwards(self, orm):
}
}

complete_apps = ['badges']
complete_apps = ['badges']
Empty file.
40 changes: 16 additions & 24 deletions gamification/settings.py → gamification/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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")

Expand All @@ -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.
Expand Down Expand Up @@ -167,11 +162,11 @@
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",

# theme
"pinax_theme_bootstrap",
"django_forms_bootstrap",

# external
"account",
"metron",
Expand All @@ -181,7 +176,7 @@
"rest_framework",
"corsheaders",
"mptt",

# project
"gamification",
"gamification.badges",
Expand Down Expand Up @@ -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',
Expand Down
24 changes: 24 additions & 0 deletions gamification/settings/default.py
Original file line number Diff line number Diff line change
@@ -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')
23 changes: 23 additions & 0 deletions gamification/settings/docker.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down