-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create backend production server for django #30
Open
SouradeepSaha
wants to merge
9
commits into
UW-Path:master
Choose a base branch
from
SouradeepSaha:FEAT-multi-environment
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0e139f6
created prod, dev, and int environment for django backend
JodyZ0203 2b5dcc7
modifies settings
JodyZ0203 f310070
modified docker file
JodyZ0203 eaa603d
added cors whitelist
JodyZ0203 6ab40bc
Merge branch 'master' into FEAT-multi-environment
SouradeepSaha 87badfa
Merge branch 'master' into FEAT-multi-environment
SouradeepSaha fa565b3
Changes to docker file and removed duplicate files
JodyZ0203 39ea432
Merge branch 'master' into FEAT-multi-environment
JodyZ0203 db4699b
modified int to dev and dev to local to follow the naming changes.
JodyZ0203 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.7 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV DJANGO_SETTINGS_MODULE uwpath_backend.dev | ||
RUN mkdir /code | ||
WORKDIR /code | ||
COPY requirements.txt /code/ | ||
RUN pip install -r requirements.txt | ||
COPY . /code/ | ||
ENV PATH /code/:$PATH | ||
EXPOSE $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.7 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV DJANGO_SETTINGS_MODULE uwpath_backend.prod | ||
RUN mkdir /code | ||
WORKDIR /code | ||
COPY requirements.txt /code/ | ||
RUN pip install -r requirements.txt | ||
COPY . /code/ | ||
ENV PATH /code/:$PATH | ||
EXPOSE $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ django-cors-headers==3.3.0 | |
postgres==3.0.0 | ||
gunicorn==20.0.4 | ||
cx_Oracle == 8.3.0 | ||
psycopg2-binary==2.8.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
""" | ||
Django settings for uwpath_backend project. | ||
|
||
Generated by 'django-admin startproject' using Django 3.0. | ||
|
||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.0/topics/settings/ | ||
|
||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/3.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__))) | ||
|
||
|
||
|
||
# HTTPS Settings | ||
#SESSION_COOKIE_SECURE = True | ||
#CSRF_COOKIE_SECURE = True | ||
#SECURE_SSL_REDIRECT = True | ||
|
||
# HSTS Settings | ||
#SECURE_HSTS_SECONDS = 31536000 # 1 year | ||
#SECURE_HSTS_PRELOAD = True | ||
#SECURE_HSTS_INCLUDE_SUBDOMAINS = True | ||
|
||
|
||
#STATIC_URL = '/static/' | ||
#STATIC_ROOT = '/code/static/' | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = os.getenv("SECRET_KEY") | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = False | ||
|
||
ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost', 'backend', 'parallel.uwpath.com'] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'app.apps.UwpathConfig', | ||
'rest_framework', | ||
'corsheaders' | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'corsheaders.middleware.CorsMiddleware', | ||
'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 = 'uwpath_backend.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': ['templates'], | ||
'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 = 'uwpath_backend.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.oracle', | ||
'NAME': os.getenv("ORACLE_DSN"), | ||
'USER': os.getenv("DB_USER"), | ||
'PASSWORD': os.getenv("DB_PASS"), | ||
'HOST': os.getenv("DB_HOST"), | ||
'PORT': os.getenv("DB_PORT") | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/3.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/3.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/3.0/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
|
||
|
||
STATICFILES_DIRS = [ | ||
'app/static/', | ||
] | ||
|
||
|
||
STATIC_ROOT = os.path.join(BASE_DIR, "static/") | ||
|
||
# Note for emails to work please set up env variables. Note: You might need to restart your computer | ||
|
||
# For sending emails | ||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
DEFAULT_FROM_EMAIL = os.environ.get('UWPath_Email_Account') | ||
SERVER_EMAIL = os.environ.get('UWPath_Email_Account') | ||
EMAIL_HOST = os.environ.get('UWPath_Host') | ||
EMAIL_PORT = 587 | ||
EMAIL_HOST_USER = os.environ.get('UWPath_Email_Account') | ||
EMAIL_HOST_PASSWORD = os.environ.get('UWPath_Email_Password') | ||
EMAIL_USE_TLS = True | ||
|
||
REST_FRAMEWORK = { | ||
'DEFAULT_RENDERER_CLASSES': ( | ||
'rest_framework.renderers.JSONRenderer', | ||
) | ||
} | ||
|
||
CORS_ORIGIN_ALLOW_ALL=True | ||
|
||
CORS_ORIGIN_WHITELIST = [ | ||
'http://localhost:8000', | ||
'http://localhost:8080', | ||
'http://127.0.0.1:8000', | ||
'http://0.0.0.0:8000', | ||
'http://129.153.61.57', | ||
'http://parallel.uwpath.com', | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to expose this secret key like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be okay, we could throw env variable in there.