Commit 84ccbb99 authored by mdsecurity's avatar mdsecurity

environment viariables work now

I goofed and named something wrong 馃挬 now environment vairables should be configurable from the docker-compose.yml
parent c6276760
Pipeline #500 passed with stage
in 7 minutes and 32 seconds
FROM python:2.7
ENV PYTHONUNBUFFERED 1
# currently this doesnt do anything
ENV host=* \
email_domain=@masonlive.gmu.edu \
cas_url=https://nanderson.me/cas/ \
superuser=dhaynes3 \
SECRET_KEY=much-secret \
DB_NAME=go \
DB_USER=go \
DB_PASSWORD=go \
DB_HOST= \
PIWIK_SITE_ID= \
PIWIK_URL= \
EMAIL_HOST= \
EMAIL_PORT= \
EMAIL_HOST_USER= \
EMAIL_HOST_PASSWORD=
RUN mkdir /go
WORKDIR /go
ADD requirements.txt /go/
......
......@@ -4,27 +4,27 @@ services:
build: .
ports:
- '8000:8000'
command: /bin/bash ./startup.sh #python go/manage.py runserver 0.0.0.0:8000
command: /bin/bash ./startup.sh -python go/manage.py runserver 0.0.0.0:8000
volumes:
- .:/go
depends_on:
- db
# environment:
# host: '*'
# email_domain: '@masonlive.gmu.edu'
# cas_url: 'https://nanderson.me/cas/'
# superuser: 'dhaynes3'
# SECRET_KEY: 'much-secret'
# DB_NAME: 'go'
# DB_USER: 'go'
# DB_PASSWORD: 'go'
# DB_HOST: ''
# PIWIK_SITE_ID: ''
# PIWIK_URL: ''
# EMAIL_HOST: ''
# EMAIL_PORT: ''
# EMAIL_HOST_USER: ''
# EMAIL_HOST_PASSWORD: ''
environment:
- test=*
- email_domain=@masonlive.gmu.edu
- cas_url=https://nanderson.me/cas/
- superuser=dhaynes3
- SECRET_KEY=much-secret
- DB_NAME=go
- DB_USER=go
- DB_PASSWORD=go
- DB_HOST=db
- PIWIK_SITE_ID=
- PIWIK_URL=
- EMAIL_HOST=
- EMAIL_PORT=
- EMAIL_HOST_USER=
- EMAIL_HOST_PASSWORD=
db:
image: mysql
environment:
......
#Create a new file 'settings.py' and copy these contents into that file
# Create a new file 'settings.py' and copy these contents into that file
import secret
import os
AUTH_MODE = "CAS"
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 mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = True
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',
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'go',
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASSWORD'],
'HOST': 'db',
'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
# The domains this application will be deployed on
# e.g. Which domains this app should listen to requests from.
ALLOWED_HOSTS = ['*']
# Peoplefinder API
PF_URL = "http://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/'),
os.path.join(BASE_DIR, 'media/'),
)
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
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
}
}
]
{
'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',
......@@ -83,69 +83,69 @@ MIDDLEWARE_CLASSES = (
'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',
'piwik',
'django.contrib.admin',
'qrcode',
'crispy_forms',
'bootstrap3_datetime',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'go',
'piwik',
'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,
},
}
}
'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',
'django.contrib.auth.backends.ModelBackend',
)
if AUTH_MODE.lower() == 'ldap':
import ldap
AUTHENTICATION_BACKENDS += (
'django_auth_ldap.backend.LDAPBackend',
'django_auth_ldap.backend.LDAPBackend',
)
AUTH_LDAP_SERVER_URI = "ldaps://directory.gmu.edu:636" # server url
AUTH_LDAP_BIND_DN = "ou=people,o=gmu.edu" # bind DN
AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True # use the user
......@@ -160,41 +160,41 @@ if AUTH_MODE.lower() == 'ldap':
"email": "mail"
}
AUTH_LDAP_ALWAYS_UPDATE_USER = True
elif AUTH_MODE.lower() == 'cas':
CAS_SERVER_URL = os.environ['cas_url']
CAS_SERVER_URL = "https://nanderson.me/cas/"
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',
)
PIWIK_SITE_ID = secret.PIWIK_SITE_ID
PIWIK_URL = secret.PIWIK_URL
CRISPY_TEMPLATE_PACK = 'bootstrap3'
# Mail settings
# 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']
# Domain used to email to users. See line 231 in views.py
# ie. in Mason's case '@masonlive.gmu.edu'
EMAIL_DOMAIN = "@masonlive.gmu.edu"
\ No newline at end of file
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