Docker now compat. with new settings layout

- Simplifies docker actually
parent 7dae59bf
Pipeline #1191 passed with stage
in 59 seconds
...@@ -11,20 +11,22 @@ services: ...@@ -11,20 +11,22 @@ services:
depends_on: depends_on:
- db - db
environment: environment:
- debug=True - GO_ALLOWED_HOSTS=*
- host=* - GO_EMAIL_DOMAIN=@masonlive.gmu.edu
- email_domain=@masonlive.gmu.edu - GO_CAS_URL=https://cas.srct.gmu.edu/
- cas_url=https://cas.srct.gmu.edu/ - GO_DB_NAME=go
- GO_DB_USER=go
- GO_DB_PASSWORD=go
- GO_DB_HOST=db
- GO_DB_PORT=3306
- GO_EMAIL_HOST=
- GO_EMAIL_PORT=
- GO_EMAIL_HOST_USER=
- GO_EMAIL_HOST_PASSWORD=
- GO_EMAIL_FROM=
- GO_EMAIL_TO=
- superuser=dhaynes3 - superuser=dhaynes3
- DB_NAME=go
- DB_USER=go
- DB_PASSWORD=go
- DB_HOST=db
- PIWIK_URL=
- EMAIL_HOST=
- EMAIL_PORT=
- EMAIL_HOST_USER=
- EMAIL_HOST_PASSWORD=
db: db:
image: mysql image: mysql
environment: environment:
......
...@@ -73,7 +73,6 @@ TEMPLATES = [ ...@@ -73,7 +73,6 @@ TEMPLATES = [
'loaders': [ 'loaders': [
'django.template.loaders.app_directories.Loader' 'django.template.loaders.app_directories.Loader'
], ],
'debug': DEBUG
} }
} }
] ]
......
import os
# Create a new file 'secret.py' and copy these contents into that file
# Please be sure to keep these variables secret in production
# You can generate a secret key from the following link: http://www.miniwebtool.com/django-secret-key-generator/
SECRET_KEY = os.environ['SECRET_KEY']
# Use the values from the database configuration
DB_NAME = os.environ['DB_NAME']
DB_USER = os.environ['DB_USER']
# Remember to use a strong password in production
DB_PASSWORD = os.environ['DB_PASSWORD']
# Often left blank
DB_HOST = os.environ['DB_HOST']
# Set piwik server site id (piwik can track multiple websites)
#PIWIK_SITE_ID = os.environ['PIWIK_SITE_ID']
# Point to the piwik url
#PIWIK_URL = os.environ['PIWIK_URL']
# Email configuration, if necessary
EMAIL_HOST = os.environ['EMAIL_HOST']
EMAIL_PORT = os.environ['EMAIL_PORT']
EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER']
EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD']
#Create a new file 'settings.py' and copy these contents into that file
from . import secret
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = os.environ['debug']
ADMINS = ()
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': secret.DB_NAME,
'USER': secret.DB_USER,
'PASSWORD': secret.DB_PASSWORD,
'HOST': secret.DB_HOST,
'PORT': '3306',
}
}
# The domains this application will be deployed on
# e.g. Which domains this app should listen to requests from.
ALLOWED_HOSTS = [os.environ['host']]
# Peoplefinder API
PF_URL = "https://api.srct.gmu.edu/pf/v1/"
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_URL = '/media/'
MEDIA_ROOT = ''
MEDIAFILES_DIRS = (
os.path.join(BASE_DIR, 'media/'),
)
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
SECRET_KEY = secret.SECRET_KEY
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.request'
],
'loaders': [
'django.template.loaders.app_directories.Loader'
],
'debug': DEBUG
}
}
]
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'settings.urls'
WSGI_APPLICATION = 'settings.wsgi.application'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'go',
'django.contrib.admin',
'qrcode',
'crispy_forms',
'bootstrap3_datetime',
)
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
CAS_SERVER_URL = os.environ['cas_url']
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
AUTHENTICATION_BACKENDS += (
'cas.backends.CASBackend',
)
CAS_RESPONSE_CALLBACKS = (
'go.cas_callbacks.create_user',
)
INSTALLED_APPS += (
'cas',
)
MIDDLEWARE_CLASSES += (
'cas.middleware.CASMiddleware',
)
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# Mail settings
EMAIL_HOST = secret.EMAIL_HOST
EMAIL_PORT = secret.EMAIL_PORT
EMAIL_HOST_USER = secret.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
EMAIL_FROM = "example@example.com"
EMAIL_TO = "to@example.com"
# Domain used to email to users. See line 231 in views.py
# ie. in Mason's case '@masonlive.gmu.edu'
EMAIL_DOMAIN = os.environ['email_domain']
# dummy cache for development-- doesn't actually cache things
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
...@@ -3,13 +3,10 @@ until nc -z db 3306; do ...@@ -3,13 +3,10 @@ until nc -z db 3306; do
sleep 1 sleep 1
done done
cp go/settings/settings.docker.py.template go/settings/settings.py export GO_SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
cp go/settings/secret.docker.py.template go/settings/secret.py
export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
python go/manage.py flush --no-input python go/manage.py flush --no-input
python go/manage.py makemigrations python go/manage.py makemigrations
python go/manage.py makemigrations go python go/manage.py makemigrations go
python go/manage.py migrate python go/manage.py migrate
python go/manage.py createsuperuser --noinput --username=$superuser --email=$superuser$email_domain python go/manage.py createsuperuser --noinput --username=$superuser --email=$superuser$GO_EMAIL_DOMAIN
python go/manage.py runserver 0.0.0.0:8000 python go/manage.py runserver 0.0.0.0:8000
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