Move env variables to envfile

This commit is contained in:
redfast00 2020-07-25 13:32:38 +02:00
parent 79fc7413c9
commit 7d23ee6044
4 changed files with 23 additions and 20 deletions

View file

@ -12,9 +12,6 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
import os import os
from django.core.exceptions import ImproperlyConfigured
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -22,12 +19,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '2r@t7^g4-@980!oo-v!1+wj+0o^s&m(+yyyt#2&k2e!ao*b$g5' SECRET_KEY = os.getenv('SECRET_KEY', '2r@t7^g4-@980!oo-v!1+wj+0o^s&m(+yyyt#2&k2e!ao*b$g5')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = os.getenv('DEBUG', '1') == '1'
ALLOWED_HOSTS = [] ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',')
# Application definition # Application definition

View file

@ -4,10 +4,8 @@ services:
build: . build: .
ports: ports:
- "8000:8000" - "8000:8000"
environment: env_file: 'web.env'
DATABASE_HOST: 'database' restart: on-failure
CELERY_BROKER: 'redis://redis:6379/0'
CELERY_BACKEND: 'redis://redis:6379/1'
depends_on: depends_on:
- database - database
command: > command: >
@ -17,10 +15,8 @@ services:
celery-worker: celery-worker:
build: . build: .
environment: env_file: 'web.env'
DATABASE_HOST: 'database' restart: on-failure
CELERY_BROKER: 'redis://redis:6379/0'
CELERY_BACKEND: 'redis://redis:6379/1'
depends_on: depends_on:
- web - web
- redis - redis
@ -30,10 +26,8 @@ services:
celery-beat: celery-beat:
build: . build: .
environment: env_file: 'web.env'
DATABASE_HOST: 'database' restart: on-failure
CELERY_BROKER: 'redis://redis:6379/0'
CELERY_BACKEND: 'redis://redis:6379/1'
depends_on: depends_on:
- web - web
- redis - redis
@ -47,6 +41,7 @@ services:
# Db stuff # Db stuff
database: database:
image: mariadb:10.5.4-focal image: mariadb:10.5.4-focal
restart: on-failure
environment: environment:
MYSQL_ROOT_PASSWORD: example MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: kers MYSQL_DATABASE: kers

View file

@ -22,8 +22,8 @@ class UserMetaForm(ModelForm):
model = CustomUser model = CustomUser
fields = ['real_name', 'student_number'] fields = ['real_name', 'student_number']
widgets = { widgets = {
'real_name': TextInput(attrs={'placeholder': 'Robbe Van Herck'}), 'real_name': TextInput(attrs={'placeholder': 'Robbe Van Herck'}),
'student_number': TextInput(attrs={'placeholder': '01701111'}) 'student_number': TextInput(attrs={'placeholder': '001700000', 'pattern': '[0-9]*'})
} }

11
web.env Normal file
View file

@ -0,0 +1,11 @@
DATABASE_HOST=database
CELERY_BROKER=redis://redis:6379/0
CELERY_BACKEND=redis://redis:6379/1
SECRET_KEY=REPLACEME
DEBUG=1
SERVER_URL=http://localhost:8000
OAUTH_CLIENT_ID=REPLACEME
OAUTH_CLIENT_SECRET=REPLACEME
KERS_ADMIN_USERNAME=replaceme
KERS_ADMIN_PASSWORD=replaceme
ALLOWED_HOSTS=localhost