Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

greut/chain-reaction

Repository files navigation

Chain Reaction

https://travis-ci.org/greut/chain-reaction.svg?branch=master https://coveralls.io/repos/github/greut/chain-reaction/badge.svg?branch=master

Le game.

Setup

$ pipenv install --dev
$ docker-compose up -d

Create the chain_reaction/settings/local.py file:

from .base import *  # noqa

ADMINS = (('Yoan Blanc', 'yoan@dosimple.ch'), )

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'chain_reaction',
        'USER': 'chain_reaction',
        'PASSWORD': 'chain_reaction',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

if IN_TESTING:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': '/tmp/chain_reaction_test.db',
        }
    }

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 1025

REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379

# Social Auth (see below)

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '...'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = '...'

SOCIAL_AUTH_FACEBOOK_KEY = '...'
SOCIAL_AUTH_FACEBOOK_SECRET = '...'

SOCIAL_AUTH_GITHUB_KEY = '...'
SOCIAL_AUTH_GITHUB_SECRET = '...'

# Static

STATIC_ROOT = "../public/static"

And continue.

$ pipenv shell
(chain-reaction) $ export DJANGO_SETTINGS_MODULE=chain_reaction.settings.local
(chain-reaction) $ python manage.py migrate
(chain-reaction) $ python manage.py createsuperuser
(chain-reaction) $ python manage.py collectstatic
(chain-reaction) $ honcho start

Profit!

Social Login

Google OAuth 2.0

Create a project on Google APIs, enable Google+ API and follow the instructions.

  • Which API are your using? Google+ API
  • Where will you be calling the API from? Web browser (Javascript)
  • What data will you be accessing? User data
  • Authorized JavaScript origins? http://localhost:8000
  • Authorized redirect URIs? http://localhost:8000/complete/google-oauth2/

Documentation

Facebook OAuth 2.0

Create an appliation on Facebook developers and enable Facebook Login.

  • Valid OAuth redirect URIs? http://localhost:8000/complete/facebook

Documentation

GitHub OAuth 2.0

Create a new application on Github.

  • Authorization callback URL? http://localhost:8000/complete/github

Documentation

For Github, you must create at least two applications for production and development as you cannot entre more than one callback URL.

No Github?

Syncing with a remote repository (or just use Github).

$ ssh srvz "git init --bare app.git"
$ git remote add srvz ssh://srvz/home/yoan/app.git
$ git push --set-upstream srvz master

Assets

The assets must be rebuild if you change anything.

$ npm install
$ npx webpack -p
# or
$ npx webpack --mode=development --watch

Updating requirements

$ pipenv lock -r > requirements.txt

Deployment

$ cd /var/www
$ git clone ... app
$ cd app
$ python3 -m venv venv
$ . venv/bin/activate
$ pip install -U pip
$ pip install -r requirements.txt
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py collectstatic

$ run daphne # see Procfile
$ run worker # see Procfile
$ configure nginx.conf ... # todo

Poor man's Capistrano

Adapt and upload deploy.sh to your server and run it through ssh.

$ ssh srvz path/to/deploy.sh

About

Django (1.x) application using Channels (1.x) to play Chain Reaction

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published