Skip to content

Commit

Permalink
Merge pull request #29 from CheesecakeLabs/bernardo/boilerplate-v2
Browse files Browse the repository at this point in the history
Update project folders structure and dependencies version
  • Loading branch information
smaniotto authored Feb 22, 2018
2 parents b7eb099 + a737e18 commit ae1f225
Show file tree
Hide file tree
Showing 67 changed files with 91 additions and 106 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
FROM python:3.5-onbuild
FROM python:3.6-jessie

COPY install.sh /usr/src/app
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ENTRYPOINT ["sh", "install.sh"]
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt

COPY . /usr/src/app
COPY docker-entrypoint.sh /usr/src/app

ENTRYPOINT ["sh", "docker-entrypoint.sh"]
6 changes: 3 additions & 3 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Boilerplate project using Django and Django REST Framework.
Currently supporting only Python 3.x.

**IMPORTANT**:
Make sure you have Django 1.10 installed on your environment.
**IMPORTANT**:
Make sure you have Django 2.0 installed on your environment.
Docker Compose is used *just* for development environment. The Dockerfile works without it.

## How to install
Expand All @@ -15,7 +15,7 @@ $ django-admin.py startproject \
--template=https://github.com/CheesecakeLabs/django-drf-boilerplate/archive/master.zip \
<project_name> .
$ pip install -r requirements.txt
$ python <project_name>/manage.py runserver
$ python src/manage.py runserver
```

## How to install with Docker Compose
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
version: '2'
version: '3'
services:
web:
build: .
volumes:
- ".:/usr/src/app"
- .:/usr/src/app
ports:
- "8000:8000"
environment:
ENV: "development"
- 8000:8000

db:
image: postgres:latest
image: postgres:9.6.6
ports:
- "5432:5432"
- 5432:5432
volumes:
- "./docker/db/pgdata:/var/lib/postgresql/data"
- ./docker/db/pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: "postgres"
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: app
4 changes: 2 additions & 2 deletions install.sh → docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ if [ "$ENV" = "development" ] ; then
python docker/web/check_db.py --service-name Postgres --ip db --port 5432
fi

python manage.py migrate
python manage.py runserver 0.0.0.0:8000
python src/manage.py migrate
python src/manage.py runserver 0.0.0.0:8000
Empty file removed project_name/__init__.py
Empty file.
2 changes: 0 additions & 2 deletions project_name/local.example.env

This file was deleted.

11 changes: 0 additions & 11 deletions project_name/urls.py

This file was deleted.

16 changes: 0 additions & 16 deletions project_name/wsgi.py

This file was deleted.

30 changes: 16 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
appdirs==1.4.0
Django==1.10.5
django-allauth==0.30.0
django-rest-auth==0.9.0
djangorestframework==3.5.3
flake8==3.3.0
mccabe==0.6.1
packaging==16.8
pycodestyle==2.3.1
pyflakes==1.5.0
psycopg2==2.6.2
pyparsing==2.1.10
six==1.10.0
django-environ==0.4.3
# Lint
flake8==3.5.0

# Django
Django==2.0.1
django-environ==0.4.4

# Django-REST-Framework
djangorestframework==3.7.7

# Authentication
django-allauth==0.35.0
django-rest-auth==0.9.3

# Postgres Driver
psycopg2==2.7.3.2
4 changes: 4 additions & 0 deletions src/app/local.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DJANGO_SECRET_KEY=fr5r80uji*^IPcd809_OUCT&D&80pi
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,
DATABASE_URL=postgres://postgres:postgres@db:5432/app
68 changes: 23 additions & 45 deletions project_name/settings.py → src/app/settings.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
"""
Django settings for {{ project_name }} project.
Generated by 'django-admin startproject' using Django 1.10.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os
from os.path import dirname, join, exists, abspath

import environ
import environ

# Load operating system env variables and prepare to use them
env = environ.Env()
Expand All @@ -28,27 +16,25 @@
BASE_DIR = dirname(dirname(abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('DJANGO_SECRET_KEY', default='8#ubdv*jh_1u(6m4)^s^*pdo!&y_#jz)vv%5cp%8^*&%ztttxq')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DJANGO_DEBUG', False)

ALLOWED_HOSTS = []
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', [])

# Application definition

INSTALLED_APPS = [
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.staticfiles',
]

THIRD_PARTY_APPS = [
'rest_framework',
'rest_framework.authtoken',

Expand All @@ -59,10 +45,14 @@

'rest_auth',
'rest_auth.registration',
]

PROJECT_APPS = [
'cklauth',
]

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand All @@ -73,7 +63,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = '{{ project_name }}.urls'
ROOT_URLCONF = 'app.urls'

TEMPLATES = [
{
Expand All @@ -92,36 +82,21 @@
},
]

WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
WSGI_APPLICATION = 'app.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
'default': env.db(),
}

# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

if not DEBUG:
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
AUTH_PASSWORD_VALIDATORS = [{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
}]

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

LANGUAGE_CODE = 'en-us'

Expand All @@ -134,18 +109,21 @@
USE_TZ = True

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

STATIC_URL = '/static/'

# Default django.contrib.site ID
# Media files (uploads)

SITE_ID = 1
if DEBUG:
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
MEDIA_ROOT = 'uploads/'
MEDIA_URL = '/uploads/'

# Email settings

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = ''
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = 'no-reply@localhost'

# Django Rest Framework Settings

Expand Down
12 changes: 12 additions & 0 deletions src/app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin
from django.urls import include, path


urlpatterns = [
path('admin/', admin.site.urls),

# Enables the DRF browsable API page
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),

path('', include('cklauth.urls', namespace='cklauth')),
]
7 changes: 7 additions & 0 deletions src/app/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

from django.core.wsgi import get_wsgi_application


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
application = get_wsgi_application()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions cklauth/urls.py → src/cklauth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from allauth.socialaccount import views as social_views
from django.conf import settings


app_name = 'cklauth'


urlpatterns = [
# Auth API endpoints
url(r'^api/v1/', include('cklauth.api.v1.urls')),
Expand Down
2 changes: 1 addition & 1 deletion manage.py → src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
Expand Down

0 comments on commit ae1f225

Please sign in to comment.