Commit dd2d284c authored by philippeoz's avatar philippeoz

Definindo estrutura inicial

parent a3d2a013
......@@ -42,3 +42,4 @@ coverage.xml
# Sphinx documentation
docs/_build/
.vscode
{
"python.linting.pep8Enabled": false
}
\ No newline at end of file
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN mkdir /config
ADD /config/requirements/production.pip /config/
RUN pip install -r /config/production.pip
RUN mkdir /src;
WORKDIR /src
\ No newline at end of file
upstream web {
ip_hash;
server web:8000;
}
# portal
server {
location /static/ {
autoindex on;
alias /staticfiles/;
}
location /media/ {
autoindex on;
alias /mediafiles/;
}
location / {
proxy_pass http://web/;
}
listen 8000;
server_name localhost;
client_max_body_size 20M;
}
\ No newline at end of file
click==6.7
dj-database-url==0.4.2
Django==2.0.1
python-decouple==3.1
python-dotenv==0.7.1
pytz==2017.3
"""
Django settings for diario_manager project.
Generated by 'django-admin startproject' using Django 2.0.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=b+8s@l*rnqjd*=1rrsp!op82-qcgubm6oysex+thbu1+myen-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'diario_manager.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 = 'diario_manager.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/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/2.0/howto/static-files/
STATIC_URL = '/static/'
version: '2'
services:
nginx:
image: nginx:latest
container_name: nginx_diario_manager
ports:
- "80:80"
volumes:
- ./src:/src
- ./config/nginx:/etc/nginx/conf.d
- static-data:/staticfiles
- media-data:/mediafiles
depends_on:
- web
web:
build: .
container_name: django_diario_manager
command: bash -c "python manage.py migrate && python manage.py collectstatic --no-input && gunicorn backend.wsgi:application -b 0.0.0.0:8000 --workers 3 --log-level=debug"
volumes:
- ./src:/src
- static-data:/src/frontend/staticfiles
- media-data:/src/media
expose:
- "80"
environment:
DEBUG: "False"
DATABASE_URL: "postgres://banco:pass@diario.com.br/diario_manager"
SECRET_KEY: "=b+8s@l*rnqjd*=1rrsp!op82-qcgubm6oysex+thbu1+myen-"
volumes:
static-data:
media-data:
\ No newline at end of file
python-3.6.2
\ No newline at end of file
DEBUG=True
DATABASE_URL=postgres://postgres:pamonha123@localhost/diario_manager
SECRET_KEY='=b+8s@l*rnqjd*=1rrsp!op82-qcgubm6oysex+thbu1+myen-'
\ No newline at end of file
......@@ -2,8 +2,18 @@
import os
import sys
from dotenv import load_dotenv
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "diario_manager.settings")
debug = os.environ.get('DEBUG')
if not debug:
dotenv_path = os.path.join(os.path.dirname(__file__), 'config.env')
load_dotenv(dotenv_path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
......
from .base import *
from .security import *
from .static import *
# Load a `local.py` module, if it exists
try:
from .local import *
except ImportError:
pass
\ No newline at end of file
from decouple import config
from dj_database_url import parse as db_url
from unipath import Path
BASE_DIR = Path(__file__).ancestor(2)
DEBUG = config('DEBUG', default=False, cast=bool)
# Active Apps
INSTALLED_APPS = [
# Django built-in apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Local apps
# 'backend.core',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Third-party middlewares
# 'whitenoise.middleware.WhiteNoiseMiddleware',
]
# Url and GateWay Config
ROOT_URLCONF = 'backend.urls'
SITE_ID = 1
WSGI_APPLICATION = 'backend.wsgi.application'
# Database
DATABASES = {
'default': config(
'DATABASE_URL',
cast=db_url
),
}
# Internationalization
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Fortaleza'
USE_I18N = True
USE_L10N = True
USE_TZ = False
USE_THOUSAND_SEPARATOR = True
DATE_INPUT_FORMATS = ('%d-%m-%Y', '%Y-%m-%d')
# Login Configs
# LOGIN_URL = '/login/'
# LOGOUT_URL = '/logout/'
# LOGIN_REDIRECT_URL = '/'
from decouple import Csv, config
# Key for salting hashes and such
SECRET_KEY = config('SECRET_KEY', default='changeme')
# Host names allowed when DEBUG=False
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='*', cast=Csv())
# Password validation
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',
},
]
from decouple import config
from .base import BASE_DIR, DEBUG
# URLs to serve media and static files
# STATIC_URL = '/static/'
# MEDIA_URL = '/media/'
MEDIA_URL = config('MEDIA_URL', default='/media/')
STATIC_URL = config('STATIC_URL', default='/static/')
# Directories to save media and compiled static files
# STATIC_ROOT = 'staticfiles'
# MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_ROOT = BASE_DIR.child('frontend', 'staticfiles')
MEDIA_ROOT = BASE_DIR.child('media')
# Directories to find static files
# STATICFILES_DIRS = (
# os.path.join(BASE_DIR, 'static'),
# )
STATICFILES_DIRS = [
BASE_DIR.child('frontend', 'static'),
# BASE_DIR.child('frontend', 'bower_components'),
]
# Static files finding engines
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'compressor.finders.CompressorFinder',
]
# Pre-processing and compression
# _bower = BASE_DIR.child('frontend', 'bower_components')
# _sass_includes = ' '.join(
# ['--include-path={}'.format(_bower.child('susy', 'sass')), ]
# )
# COMPRESS_PRECOMPILERS = [
# ('text/x-scss', 'sassc {infile} {outfile} ' + _sass_includes),
# ]
# COMPRESS_PRECOMPILERS = [
# ('text/x-scss', 'sassc {infile} {outfile}'),
# ]
COMPRESS_CSS_FILTERS = [
'compressor.filters.cssmin.rCSSMinFilter',
]
COMPRESS_JS_FILTERS = [
'compressor.filters.jsmin.JSMinFilter',
]
# Template finders and processors
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
BASE_DIR.child('frontend', 'templates'),
],
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.media',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
},
},
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment