Skip to content

Commit

Permalink
Merge branch 'master' of github.com:audaciouscode/PassiveDataKit-Django
Browse files Browse the repository at this point in the history
  • Loading branch information
audaciouscode committed Jul 31, 2016
2 parents 4ba6688 + b58fc1e commit 2b45303
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ docs/_build/

# PyBuilder
target/

Dockerfile
Procfile

37 changes: 37 additions & 0 deletions Dockerfile.aptible
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dockerfile
FROM quay.io/aptible/ubuntu:14.04

ADD .aptible.env /app/
RUN cat /app/.aptible.env

RUN apt-install software-properties-common wget
RUN add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Basic dependencies
RUN apt-install build-essential python-dev python-setuptools
RUN apt-install libxml2-dev libxslt1-dev python-dev

# PostgreSQL dev headers and client (uncomment if you use PostgreSQL)
RUN apt-install libpq-dev postgresql-client-9.5

RUN easy_install pip

# Add requirements.txt ONLY, then run pip install, so that Docker cache won't
# bust when changes are made to other repo files
ADD requirements.txt /app/
WORKDIR /app
RUN pip install -r requirements.txt

RUN django-admin startproject pdk
ADD . pdk/passive_data_kit
ADD aptible_settings.py pdk/pdk/settings.py
ADD aptible_wsgi.py pdk/pdk/wsgi.py

# WORKDIR /app/pdk
# RUN set -a && . /app/.aptible.env && python manage.py migrate
# RUN set -a && . /app/.aptible.env && python manage.py collectstatic

ENV PORT 3000
EXPOSE 3000

3 changes: 3 additions & 0 deletions Procfile.aptible
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Procfile
web: gunicorn --pythonpath /app/pdk/ pdk.wsgi --log-file - --bind="0.0.0.0:$PORT"

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

[![Build Status](https://travis-ci.org/audaciouscode/PassiveDataKit-Django.svg?branch=master)](https://travis-ci.org/audaciouscode/PassiveDataKit-Django)

## Aptible Deployments

Passive Data Kit now supports standalone deployments to [Aptible](https://www.aptible.com/) for secure installations handling personal health information (PHI).

To deploy to Aptible:

1. Check out this repository to a local location.
2. Create a new branch of this repository.
3. Rename `Dockerfile.aptible` to `Dockerfile`.
4. Rename `Procfile.aptible` to `Procfile`.
5. Add the renamed files to the new branch.
6. Set up your Aptible environment as described in the [Django Quickstart Guide](https://support.aptible.com/quickstart/python/django).
7. Push your new branch to the remote repository specified by Aptible.
8. Upon successful deployment, log into an interactive terminal using the `aptible ssh` command and run the `migrate`, `collectstatic`, and `createsuperuser` tasks to initialize your Django environment.
9. Exit the terminal and access the Passive Data Kit data administration interface via `https://aptible.url/data/` or the Django admin at `https://aptible.url/data/`.

This is an early feature, so please log any bugs or other issues to the project's issue tracker.

## License and Other Project Information

Copyright 2015 Audacious Software

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Expand Down
87 changes: 87 additions & 0 deletions aptible_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""
Settings.py for deploying standalone site on Aptible.
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import sys

import dj_database_url

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'foobar'

DEBUG = True
ADMINS = []

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'passive_data_kit'
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
)

ROOT_URLCONF = 'passive_data_kit.travis_urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'pdk.wsgi.application'

DATABASES = {'default': dj_database_url.config()}
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
16 changes: 16 additions & 0 deletions aptible_wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Passive Data Kit project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pdk.settings")
application = DjangoWhiteNoise(get_wsgi_application())
1 change: 0 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from django.db.models.signals import post_delete
from django.dispatch.dispatcher import receiver


def generator_label(identifier):
for app in settings.INSTALLED_APPS:
try:
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ pytz==2016.4
six==1.10.0
wsgiref==0.1.2
xkcdpass==1.6.4
gunicorn==19.6.0
dj-database-url==0.4.1
whitenoise==3.2
2 changes: 1 addition & 1 deletion travis_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""royalty URL Configuration
"""Passive Data Kit URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Expand Down

0 comments on commit 2b45303

Please sign in to comment.